Skip to main content

Setting up the Klar Pixel via serverside tracking

Franz May avatar
Written by Franz May
Updated today

How to set up the Klar tracking pixel by validating your domain, implementing the tracking script, and adjusting UTM parameters.

Do you want to start using the attribution report in Klar? Great choice ๐ŸŽ‰

To power our fully integrated attribution solution, you need to configure the Klar Pixel datasource in Klar and implement a tracking script on your site. This should only take a few minutes.

If you want to implement the Klar Pixel via WooCommerce (not GTM), please consider this article

1. Adding the Klar Pixel Datasource

If you have multiple WooCommerce instances, with separate domains, connected to Klar, you should create a unique Pixel datasource for each of these stores.

  • Go to your Store Configurator page in Klar and click Connect Data Source

  • Select the Datasource Klar Pixel

  • Enter a name for the datasource - eg. Klar Tracking Script
    โ€‹

  • Configure a basic tracking script and press configure.
    โ€‹

2. Implementing the Klar script in your serverside environment

All Events should be sent to "https://september.durchsichtig.xyz/server-side-event/EVENT_NAME" with a POST request. The IP of the Customer has to be provided with the header "x-serverside-ip".

For the correct implementation you have to configure 5 different events:
โ€‹

Events to implement

  • Klar:visitEvent

  • Klar:productViewEvent

  • Klar:UpdateCartEvent

  • Klar:UpdateCheckoutEvent

  • Klar:OrderEvent

All these events are emitted by publishing a CustomEvent on the document. When the event has been successfully published a fetch event with the payload will be triggered.

2.1 Klar:visitEvent

Please trigger this event on every page of your website.

{
"pageTitle": "Best Product of the World",
"eventName": "VisitEvent",
"createdAt": "2024-04-11T11:11:15.783Z",
"pageUrl": "https://getklar.com/dogs",
"septemberId": "UNIQUE ID like a COOKIE,has to be a 16 character nanoid",
"googleAnalyticsId": "Value of the _ga cookie",
"facebookId": "Value of the _fbp cookie",
"dataSourceId": "DataSource ID can be found in the pixel data source",
"referrer": "https://google.de",
"hasGivenConsent": true,
"customerId": "When available",
"screen": "1920x1200"
}

2.2 Klar:ProductViewEvent

Please trigger this event when the customer views a product of the webshop.

{
"productId": "46667923652922",
"productTitle": "Best Dog TransportBOX",
"productSku": "F0011",
"createdAt": "2024-04-11T11:22:43.984Z",
"eventName": "ProductViewedEvent",
"pageUrl": "https://getklar.com/dogs/transport",
"septemberId": "UNIQUE ID like a COOKIE,has to be a 16 character nanoid",
"googleAnalyticsId": "Value of the _ga cookie",
"facebookId": "Value of the _fbp cookie",
"dataSourceId": "DataSource ID can be found in the pixel data source",
"referrer": "https://getklar.com/dogs",
"hasGivenConsent": true,
"customerId": "When available",
"screen": "1920x1200"
}

2.3 Klar:UpdateCartEvent

Please trigger this event when the customer changes the content of the shopping basket, e.g. adds / removes products.

{
"cartId": "123456789",
"productId": "46667923652922",
"productSku": "F0011",
"productTitle": "Best Dog TransportBOX",
"productPrice": 8.5,
"productQuantity": 1,
"eventName": "AddToCartEvent",
"createdAt": "2024-04-11T11:27:06.262Z",
"pageUrl": "https://getklar.com/dogs/transport",
"septemberId": "UNIQUE ID like a COOKIE,has to be a 16 character nanoid",
"googleAnalyticsId": "Value of the _ga cookie",
"facebookId": "Value of the _fbp cookie",
"dataSourceId": "DataSource ID can be found in the pixel data source",
"referrer": "https://getklar.com/dogs",
"customerId": "When available",
"hasGivenConsent": true,
"screen": "3840x2160"
}

2.4 Klar:UpdateCheckoutEvent

Please trigger this event when the customer enters the checkout area of your shop.

{
"checkoutId": "7297e4e6e7c95f2e8c3da4c66d60f7e7",
"createdAt": "2024-04-11T11:29:32.929Z",
"eventName": "UpdateCheckoutEvent",
"pageUrl": "https://getklar.com/checkouts/cn/Z2NwLWV1cm9wZS13ZkVKSz"
"septemberId": "UNIQUE ID like a COOKIE,has to be a 16 character nanoid",
"googleAnalyticsId": "Value of the _ga cookie",
"facebookId": "Value of the _fbp cookie",
"dataSourceId": "DataSource ID can be found in the pixel data source",
"referrer": "https://getklar.com/dogs/transport",
"hasGivenConsent": true,
"customerId": "When available",
"screen": "3840x2160"
}

2.5 Klar:OrderEvent

Please trigger this event on the "Checkout Finish" page, when the order has been placed by the customer.

{
"orderId": "5916248703148",
"customerId": "When available",
"checkoutId": "7282c2584c907ddcd9f17dd01f374137",
"checkoutItems": [{
"productId": "42897447452844",
"productSku": "12345",
"productTitle": "Dog BOX",
"productQuantity": 1,
"productPrice": 0
}],
"shippingTotal": 0,
"checkoutTax": 0,
"checkoutTotal": 629.95,
"eventName": "OrderEvent",
"createdAt": "2024-04-11T11:35:18.474Z",
"pageUrl": "https://getklar.com/checkouts/cn/Z2NwLWV1cm9wZS13ZkVKSz"
"septemberId": "UNIQUE ID like a COOKIE",
"googleAnalyticsId": "Value of the _ga cookie",
"facebookId": "Value of the _fbp cookie",
"dataSourceId": "DataSource ID provided by Klar",
"referrer": "https://getklar.com/dogs/transport",
"hasGivenConsent": true,
"screen": "3840x2160"
}

Troubleshooting

When a request is incorrect, the server returns a 400 status code along with an "X-Klar-Failure" header. The header value indicates the specific error type:
โ€‹

  • "read-headers": Missing or invalid headers in the request

  • "get-body": Wrong format or missing request body

  • "invalid-json": Body was provided but contains invalid JSON format

In case you encounter any unknown errors or bugs, please contact Pascal our customer support.

3. Adding Data Privacy Snippets

Make sure to add our data privacy snippet in your privacy policy to inform your customers about the usage of Klarโ€™s tracking pixel. You can find a German and English snippet in the Klar Pixel data source under the tracking script in a collapsed section called โ€œData Protection Snippetโ€.
โ€‹

4.Implementing Klar URL Parameters

To ensure that conversions and costs can be matched as accurately as possible, you need to implement the pre-defined Klar tracking codes in your ad accounts.

Here are guides on how to do that for each marketing channel:

What Happens Next?

Starting now, we will be able to track visitors on your site and their purchase activity to power our attribution reporting.

Starting tomorrow you will start seeing data in your reports but only from the point in time you added the script.

Did this answer your question?