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.
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
Callkontext('track', ...) from your page when the event happens:
Single-page apps
If your site changes pages without a full reload, callkontext('track', 'PageView') yourself on each route change.
How attribution works
- When someone clicks your ad, they land on your site with a
kontext_click_idparameter in the URL. We set this up with your campaign. Any redirect on your side must keep the parameter. - 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. - 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.
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: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.