1. Create the pixel and copy its id
- Meta
- TikTok
In Events Manager → Connect data → Web, name the dataset, create it, choose Set up Meta Pixel → Add code yourself. The number in
fbq('init', '…') of the base code Meta shows is the Dataset ID (Meta’s name for the Pixel ID since pixels became datasets). You can also find it under Datasets → the dataset → Settings. Paste it into Rally and pick the Purchase event Rally’s purchase-optimised ads should target (Purchase by default).2. Install the base code
The base code goes on every page, in<head>. In Next.js or React, load it once in the root layout and fire the page event on every client-side route change.
- Meta
- TikTok
<img> is not valid inside <head>; if your build tooling rejects the <noscript> block there (Vite does), put it at the top of <body>.3. Fire the two standard events
Fire each exactly once, when the thing happens. Never on page load of a generic page, on refresh, or for returning logged-in users: the ads optimise on these, so noise costs money.- Meta
- TikTok
Event names are case-sensitive standard events.Fire the purchase event from the success page only if that page knows the amount and a payment reference to use as
eventID; otherwise send it server-side only (next step), which is enough for Meta to optimise on.4. Mirror events from your server (recommended)
Browser blockers drop a share of pixel events. Sending the same events from your backend with the sameevent_id recovers them; the platform deduplicates by id. Generate the token in the platform, store it as a server secret, and paste it into Rally’s dialog (Add to prompt) so the coding-agent prompt carries it.
- Meta Conversions API
- TikTok Events API
Token: Events Manager → Datasets → the dataset → Settings → Conversions API → Generate access token. Store it as
META_CAPI_TOKEN.POST https://graph.facebook.com/v19.0/<DATASET_ID>/events with the token in the Authorization header (never in a URL), sending the same event_name (Lead, Purchase), event_time, the same event_id as the browser event, action_source: "website", and hashed user_data (em, ph, client_ip_address, client_user_agent, the fbp and fbc cookies).5. Verify from Rally
Open your site once (a page view), complete a test signup and, if you can, a test purchase. Then in Rally, Settings → Integrations → Ad accounts → the account → Conversion tracking → Verify. Rally reads back from the platform what arrived:
The Meta Pixel Helper extension, and each platform’s Events Manager → Test events, show the same live.
Rally’s own click, signup and sale numbers do not depend on the pixel; they come from the tracking snippet and your lead and sale calls. The pixel only affects how well the platform can optimise the ads.