Skip to content
trackrift

Documentation

Guides

Getting started

Install tracking, verify events, connect destinations, and understand the data flow end-to-end.

AI brief: Flow: paste universal script → verify in Settings → Tracking health → configure CNAME → connect Meta/Google CAPI in destinations. Read SDK docs for custom implementations. public_id in u.js must match workspace.

Trackrift ingests browser and server events through a collector (POST /collect), resolves identity server-side, and forwards conversions to ad platforms via CAPI. The fastest path is the Universal Script — no npm, no build step.

Prerequisites

RequirementWhere to find it
Workspace accounthttps://app.trackrift.com — sign up or sign in
public_id (12 chars)Settings → Tracking → Universal script snippet
Marketing domainSite where the script will load (HTTPS recommended)
Optional: CNAME subdomainSettings → Tracking → Custom domain (e.g. t.yourbrand.com)

Install the Universal Script

  1. Copy the snippet from Settings → Tracking (or use the placeholder below — replace YOUR_PUBLIC_ID before production).
  2. Paste in <head> as early as possible, or deploy via GTM / Webflow / Framer custom code.
  3. Publish your site. The script loads /v1/u.js?id=PUBLIC_ID, which injects accountId and enables autocapture.
  4. Open Settings → Tracking → Live verification — you should see page_view within ~5 seconds.
  5. Optional: add your domain to Allowed origins if you restrict ingest by hostname.
  6. Optional: configure a custom CNAME for first-party delivery (see CNAME guide).
  7. Connect Meta / Google / TikTok under Settings → Destinations for server-side forwarding.
your-site.html
<script async src="https://api.trackrift.com/v1/u.js?id=YOUR_PUBLIC_ID"></script>

What happens on first page load

Sequence: (1) browser requests /v1/u.js → (2) SDK calls GET /bootstrap to set _aid / _ses cookies → (3) page_view queued → (4) batch flushed to POST /collect via sendBeacon or fetch with keepalive. UTMs and click IDs from the URL are attached to the event context; UTMs are not persisted client-side (by design — see attribution docs).

manual-purchase.ts

After install — fire high-value events explicitly

// Universal script exposes window.trackrift, or use npm @trackrift/sdk
window.trackrift?.track('lead', {
  properties: { form: 'hero', plan: 'starter' },
});

const eventId = window.trackrift?.track('purchase', {
  value: 297,
  currency: 'USD',
  content_ids: ['sku_starter'],
});
// Pass eventId to Meta Pixel for dedupe — see CAPI docs

Tag managers

In GTM use a Custom HTML tag, firing on All Pages, priority above marketing pixels if you need click IDs on the first paint. Do not defer the script until DOMContentLoaded unless you accept losing early-page UTMs.

Staging vs production

Use separate Trackrift workspaces for staging and production. Never reuse the same public_id across environments — events will merge into one workspace and corrupt attribution.

Environment checklist

CheckPass criteria
Script loadsNetwork tab: u.js 200, no ad-blocker intercept
BootstrapGET /bootstrap 200; _aid cookie set on collector domain or CNAME
CollectPOST /collect 204 within 2s of page load
DashboardLive verification shows page_view with correct page.url
IdentifyAfter login, identify() or email in event links journey