Skip to main content
The Kontext pixel is a small JavaScript tag for advertisers. Install it on your website, fire an event when something you care about happens, such as a purchase or a sign-up, and we connect that event to the ad click that brought the visitor to you. Before you start, ask your Kontext contact for your pixel token.

Install the pixel

Paste this snippet into the <head> of every page where you want to track events, and replace YOUR_PIXEL_TOKEN with your token. You can also add it through a tag manager, as a custom HTML tag that runs on every page.
The PageView line is what records the page view: the pixel doesn’t track anything on its own. Calls made before the script finishes loading are queued and sent once it’s ready.

Track events

Call kontext('track', ...) from your page when the event happens:

Single-page apps

If your site changes pages without a full reload, call kontext('track', 'PageView') yourself on each route change.

How attribution works

  1. When someone clicks your ad, they land on your site with a kontext_click_id parameter in the URL. We set this up with your campaign. Any redirect on your side must keep the parameter.
  2. The pixel reads the parameter and stores it in a first-party cookie, __kx_clk, that lasts 7 days. A new click replaces the old one and restarts the 7 days.
  3. Every event sent while the cookie exists carries that click ID, so a conversion within 7 days of the click is tied to the last click.
Events from visitors who didn’t click an ad are still recorded, but as unattributed.

Checkout on another domain

A cookie doesn’t follow visitors to a different hostname, and that includes another subdomain of your site. If your checkout lives elsewhere, pass its hostname when you initialize the pixel:
The pixel then adds the click ID to links and forms that point to that hostname. Install the pixel on the checkout pages too, so it can pick the click ID up there.

Content security policy

If your site uses a content security policy, allow our host, and allow the inline snippet the way your policy allows other inline scripts, for example with a nonce:

Check your installation

Open the page with your browser’s developer tools on the Network tab, then fire an event. To test attribution, add ?kontext_click_id= and a test UUID such as 01977ad2-1f45-799a-9ee7-35540aac4456 to the URL. If a test URL had an invalid kontext_click_id, clear the __kx_clk cookie before you try again. The invalid value stays in the cookie and later events are rejected too.

Limitations

  • Attribution needs the first-party cookie, so visitors who block cookies aren’t attributed.
  • Attribution only works in the browser where the ad was clicked. A visitor who clicks on their phone and buys on their laptop isn’t attributed.
  • Ad blockers may block the pixel.