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.

HTML
<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 livesHow to add it
Plain HTML, WordPress, Webflow, ShopifyYour theme's header or "custom code in <head>" setting, on every page
Google Tag ManagerA Custom HTML tag with the snippet, triggered on All Pages
React, Next.js, Vue and other single-page appsOnce, 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.

JavaScript
// 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.

JavaScript
// 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.

.env
# Development and staging
INCREMENTALITY_WRITE_KEY=pk_test_…

# Production
INCREMENTALITY_WRITE_KEY=pk_live_…
Node.js
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 },
    }],
  }),
});
Python
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?

The pixel keeps its visitor ID in a first-party cookie named 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 fromBest forWatch out for
The browser (pixel)Page views, clicks, steps in a sign-up flow: anything that happens on screenAd blockers and closed tabs drop a few percent
Your serverPayments, renewals, refunds, anything that must be exactSend the same userId (or the inc_aid visitor ID) so it joins the person
One place per eventSend each event from one side only: a purchase from the server, the click that led to it from the browserSending 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:

EventWhenUseful properties
page_viewedAutomaticurl, path, utm_*
signed_upAn account is createdplan, method
activatedThe first meaningful action (the first song played, project created…)what
order_completedA purchase or subscription startsrevenue, currency, plan
subscription_canceledSomeone leavesreason

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_…").

OptionDoes
autoPageviewsSet false to send page views yourself with inc("page")
cookieDomainShare the visitor across subdomains, e.g. ".brand.com" for www and app
consentStarting consent, e.g. { analytics: false } where consent comes first
withoutConsent"cookieless" (default) or "none" before analytics consent
campaignParamsExtra query parameters to keep as campaign data, e.g. ["cid"]

Consent banners and regional rules are covered in privacy and consent.