Install Motif in application code
The tracker is a deferred script. Identify and milestones are browser calls. Stripe Connect remains the only revenue writer.
Tracker
Put this tag in the first HTML document a visitor hits (root layout or index.html). Replace WEBSITE_ID with the id from Websites. A reverse-proxy install can serve the same file from your own host; the script posts events relative to its own URL.
<script defer src="https://collect.motiftrace.com/m.js" data-website-id="WEBSITE_ID"></script>
The tracker is a no-op on localhost unless the tag includes data-allow-localhost. Sends use text/plain so the beacon stays a CORS-simple request.
Identify a signed-in user
Call identify with the product's stable internal user id after authentication. Never pass an email, name, or profile field. Motif HMAC-hashes the id on the server and never stores the raw value.
window.motif?.identify(currentUser.id)
Canonical milestones
Record signup after the account exists. Record checkout_started immediately before a server-created Checkout Session or a Stripe Pricing Table. Payment Links and Buy Buttons emit checkout_started from the tracker on click; do not double-fire those.
window.motif?.track("signup_completed")
window.motif?.track("checkout_started")
Stripe success URL
If your backend creates Checkout Sessions, keep Stripe's placeholder on the success URL. Motif reads session_id off that page and joins the visitor to the payment. The tracker never accepts an amount.
https://yoursite.com/thanks?session_id={CHECKOUT_SESSION_ID}
{CHECKOUT_SESSION_ID} is Stripe's literal token. Do not replace it. Passing client_reference_id yourself still works and wins when present. Payment Links, Buy Buttons, and Pricing Tables get that stamp from the tracker.
Give this task to a coding agent
Replace TRACKER_ORIGIN and WEBSITE_ID, then paste:
Install Motif's deferred tracker script from TRACKER_ORIGIN/m.js with
data-website-id="WEBSITE_ID" in the application-wide HTML shell. After the
signed-in user's stable internal id is available, call motif.identify(user.id);
never pass email or profile data. Emit motif.track("signup_completed") only
after signup succeeds. Emit motif.track("checkout_started") immediately before
a server-created Checkout Session or Stripe Pricing Table checkout; do not add
it for Stripe Payment Links or Buy Buttons because the tracker handles those
clicks automatically. Preserve Stripe's {CHECKOUT_SESSION_ID} placeholder in
the success_url. Keep all calls browser-side and no-throw. Verify one pageview,
one identify event, and each applicable milestone in the browser network log,
with no email, token, or URL fragment in any payload. The raw internal id is
present only in the HTTPS identify request so Motif can HMAC it server-side; it
must not appear in Motif's stored analytics facts, responses, or logs.