Analytics
Install and instrument
Add the pixel to your site, then track signups, purchases and anything else from the browser or your servers.
One snippet gets you page views and campaign credit; a few more calls record signups, purchases and the other moments that matter. Your snippet, with keys and domains filled in, is on Analytics → Sources. Have a coding agent? It can do all of this: see AI agents.
1. Install the pixel
Paste the snippet into the <head> of every page. It loads in the background and never slows the page down.
<script>
!function(w,d,s){w.inc=w.inc||function(){(w.inc.q=w.inc.q||[]).push(arguments)};
s=d.createElement("script");s.async=1;s.src="https://incrementality.ai/px.js";d.head.appendChild(s)}(window,document);
inc("init", {
live: "pk_live_…",
test: "pk_test_…",
domains: ["brand.com"]
});
</script>It carries both of the source's keys and your site's domains, and picks by where it's running: on brand.com and its subdomains (www.brand.com, shop.brand.com) it sends live data; anywhere else (localhost, staging, preview deployments) it sends test data. So the same snippet goes in every environment, and development never touches your live reports or your plan. The live key works only from a browser on those domains: anywhere else, or from a script, it's refused, so a copied key can't fill your live data. (It stops casual misuse; floods are stopped at the edge.) Add or change domains under Your site on the source's page; until you do, the live key is refused everywhere.
| Where your site lives | How to add it |
|---|---|
| Plain HTML, WordPress, Webflow, Shopify | Your theme's header or "custom code in <head>" setting, on every page |
| Google Tag Manager | A Custom HTML tag with the snippet, triggered on All Pages |
| React, Next.js, Vue and other single-page apps | Once, in the root layout or index.html. Page views follow in-app navigation on their own; don't add the snippet per route |
Every page view arrives as page_viewed with its URL, title, referrer and every utm_* parameter, so links made with the link builder are credited with no extra work.
2. Check it works
Open your site in another tab, then look at the source's Recent events: your page view appears within a few seconds (switch to Test data if you're trying it locally). Nothing there? Check the snippet is on the page you opened, and an ad blocker isn't hiding it (try a private window). The browser console says whether it's sending test or live data, and explains anything it refuses.
3. Track what matters
Call inc("track", name, properties) when something happens. Calls made before the pixel has loaded are queued, so it's safe to call straight away.
// A form or button
document.querySelector("#signup-form").addEventListener("submit", () => {
inc("track", "signed_up", { plan: "free", method: "email" });
});
// The order confirmation page
inc("track", "order_completed", { order_id: "1001", revenue: 49, currency: "USD", items: 2 });Name events in the past tense, object first: signed_up, order_completed, song_played. Put the details in properties, not in the name (plan: "pro", not signed_up_pro), so one event can be broken down any way later. See events, properties and traits.
4. Identify people
When someone signs up or logs in, tell the pixel who they are. Their earlier anonymous visits, and the campaign that first brought them, join their profile. Use your own stable user ID, never an email address.
// After sign-up or log-in
inc("identify", "user_123", { plan: "pro" });
// On log-out, so the next person on this device starts fresh
inc("reset");5. Send server events
For anything your backend knows best (payments, renewals, refunds), create a Server source and post to the collect API with its key: the test key in development and the live key in production, from an environment variable. Send the same userId you identify with in the browser, and the event lands on the same person, with the same campaign credit.
# Development and staging INCREMENTALITY_WRITE_KEY=pk_test_… # Production INCREMENTALITY_WRITE_KEY=pk_live_…
await fetch("https://incrementality.ai/api/v1/collect", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.INCREMENTALITY_WRITE_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
batch: [{
type: "track",
event: "subscription_renewed",
userId: "user_123",
messageId: "invoice_8812", // retries with the same ID count once
properties: { revenue: 49, currency: "USD", plan: "pro" },
increment: { lifetime_revenue: 49 },
}],
}),
});import os, requests
requests.post(
"https://incrementality.ai/api/v1/collect",
headers={"Authorization": f"Bearer {os.environ['INCREMENTALITY_WRITE_KEY']}"},
json={"batch": [{
"type": "track",
"event": "subscription_renewed",
"userId": "user_123",
"messageId": "invoice_8812",
"properties": {"revenue": 49, "currency": "USD", "plan": "pro"},
}]},
timeout=5,
)Someone who hasn't logged in?
inc_aid. Read it on your server and send it as anonymousId, and a server event joins that visitor's browsing, even before they have an account.Batches take up to 500 events. Keep the key in an environment variable. It can only send events, never read them. Full details are in the collect API reference.
Browser or server?
| Send from | Best for | Watch out for |
|---|---|---|
| The browser (pixel) | Page views, clicks, steps in a sign-up flow: anything that happens on screen | Ad blockers and closed tabs drop a few percent |
| Your server | Payments, renewals, refunds, anything that must be exact | Send the same userId (or the inc_aid visitor ID) so it joins the person |
| One place per event | Send each event from one side only: a purchase from the server, the click that led to it from the browser | Sending the same purchase from both counts it twice |
A first tracking plan
Most products start well with five events, then add more as questions come up:
| Event | When | Useful properties |
|---|---|---|
page_viewed | Automatic | url, path, utm_* |
signed_up | An account is created | plan, method |
activated | The first meaningful action (the first song played, project created…) | what |
order_completed | A purchase or subscription starts | revenue, currency, plan |
subscription_canceled | Someone leaves | reason |
Approve these on Analytics → Events, and ready-made reports such as the conversion funnel and conversions by channel pick them up. See reports and dashboards.
Pixel options
Pass options as the third argument to init, e.g. inc("init", { live, test, domains }, { cookieDomain: ".brand.com" }). A single key also works in place of the keys, e.g. inc("init", "pk_test_…").
| Option | Does |
|---|---|
autoPageviews | Set false to send page views yourself with inc("page") |
cookieDomain | Share the visitor across subdomains, e.g. ".brand.com" for www and app |
consent | Starting consent, e.g. { analytics: false } where consent comes first |
withoutConsent | "cookieless" (default) or "none" before analytics consent |
campaignParams | Extra query parameters to keep as campaign data, e.g. ["cid"] |
Consent banners and regional rules are covered in privacy and consent.