Skip to main content

Setting up the Klar Pixel for WooCommerce

Connect the Klar tracking pixel to your WooCommerce store to power attribution reporting.

Written by Nico Stappen

Do you want to start using the attribution report in Klar? Great choice 🎉

To enable attribution reporting, you need to: create a Klar Pixel datasource, implement the tracking script on your site, and add your UTM parameters. This takes about 10–15 minutes.

💡 If you want to implement the Klar Pixel via Google Tag Manager, use this guide instead.


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 store.

  1. Go to Store Configurator → Data Sources and click Add New Data Source

  2. Select Klar Pixel

  3. Enter a name for the datasource (e.g. Klar Tracking Script)
    ​

  4. Choose your tracking script type and click Configure:

    • Domain Validated (first-party) — recommended

    • Basic (third-party)
      ​

  5. Select Other as Shop System

✅ We strongly recommend the Domain Validated script. It delivers the Klar JavaScript via a subdomain of your own domain, which prevents it from being blocked by browsers that restrict third-party scripts. This leads to more tracked conversions.

If you selected Basic tracking: you'll see your tracking script immediately. Skip ahead to Section 3.

If you selected Domain Validated: enter your domain name (exclude https:// and www.). Klar will generate two DNS records to add to your DNS settings with your hosting provider.

6. Copy each DNS record using the copy icon and add them to your DNS settings

7. Click Validate DNS Records

⏱ DNS validation can take a few hours — up to 2 days in rare cases. Once verified, a green check icon will appear next to the record. After validation, a Tracking Script box will appear with the script to implement on your site.


2️⃣ GoDaddy/WebGo/All Inkl/Strato hosted domain

These hosting providers display DNS record names with your full domain already appended. You need to remove it before saving.

The name field will show something like 123456789.your-shop.com — but you need to enter only the subdomain prefix:

CNAME
❌ 123456789.your-shop.com
✅ 123456789

CNAME IPv4
❌ 123456789-4.your-shop.com
✅ 123456789-4

3️⃣ Implementing the Klar script in your WooCommerce store

Download the Klar WooCommerce Pixel repository

You'll add three custom events to your WooCommerce theme that Klar needs for attribution.

Step 1 — Embed the tracking script

Paste the generated JavaScript from your Klar Pixel datasource into the <HEAD> section of your WooCommerce store template. This can be done in multiple ways depending on your setup. Contact Klar support via the in-app chat if you need help.

Step 2 — Add custom shortcodes to your theme

Find your active theme by going to Appearance → Themes.

The theme folder is typically located at:

wp-content/themes/[your-theme]/
  1. Upload custom-shortcodes.php into the root folder of your theme

  2. Modify the following files by adding the content from the corresponding files in the repository:

    • functions.php

    • checkout/thankyou.php

If checkout/thankyou.php does not exist in your theme yet, copy the original WooCommerce template from:

wp-content/plugins/woocommerce/templates/checkout/thankyou.php

…into your theme at:

wp-content/themes/[your-theme]/checkout/thankyou.php

Then add the repository content to that file.

Step 3 — Add shortcodes to your pages

  1. In WooCommerce, go to Pages → Basket and add a new Shortcode block with:

  2. Go to Pages → Checkout and add a new Shortcode block with:

Debugging

Once installed, open your browser's developer console and check the value of:

q

It should contain an array of the events that have been beeen triggered.


4️⃣ 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”.
​


5️⃣ 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?

Klar will start tracking visitor and purchase activity immediately. You'll see data in your reports from the next day — attribution is available from the moment the script went live. 🎉

Did this answer your question?