Skip to main content

Setting up the Klar Pixel via Tag Management System (Full functionality)

Track every visit, product view, cart action and order on your shop with the Klar Pixel, deployed entirely through Google Tag Manager (GTM).

Written by Franz May

tl;dr

  • Create a Klar Pixel datasource, validate your domain, and add the tracking script as a Custom HTML tag on All Pages.

  • Four events are required: Product Viewed, Add to Cart, Update Checkout and Order.

  • Remove from Cart, Shipping Info and Payment Info are recommended. They complete your funnel view per channel and campaign.

  • Send the same product ID your shop system sends to Klar. Step 4 shows which one that is for your shop system.

  • Test everything in GTM Preview before publishing. Then watch your pixel coverage build up in the Action Centre.


Before you start

You'll need:

  • Publish access to your Google Tag Manager container.

  • A data layer that fires on your key shop actions. Ideally the standard GA4 ecommerce events (view_item, add_to_cart, begin_checkout, purchase …).

  • A cart ID and checkout ID from your shop system. No IDs available? Use a session ID instead → Creating a session ID in Google Tag Manager.

  • Access to your DNS settings (for Domain Validated tracking).


Which events should I send?

Event

When to fire

GA4 data layer event

Priority

Base script (visit / page view)

Every page load

All Pages (Page View trigger)

Required

Klar:sendProductViewedEvent

Product detail page

view_item

Required

Klar:sendAddToCartEvent

Product added to cart

add_to_cart

Required

Klar:sendUpdateCheckoutEvent

Customer enters checkout

begin_checkout

Required

Klar:sendOrderEvent

Order confirmation page

purchase

Required

Klar:sendRemoveFromCartEvent

Product removed from cart

remove_from_cart

Recommended

Klar:sendShippingInfoEvent

Shipping details entered

add_shipping_info

Recommended

Klar:sendPaymentInfoEvent

Payment details entered

add_payment_info

Recommended

Klar:customConversionEvent

Any custom goal (e.g. newsletter sign-up)

your own event

Optional

Klar:signupEvent

Email captured in a signup form

your form's submit event

Optional

Why send the recommended events too? The required events cover attribution and the core funnel. Remove from Cart, Shipping Info and Payment Info show where customers drop off inside the checkout, per channel and campaign.


Step 1: Add the Klar Pixel datasource

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

  2. Select Klar Pixel.

  3. Name the datasource, e.g. Klar Tracking Script.

  4. Choose Domain Validated (recommended) or Basic and click Configure.

We strongly recommend Domain Validated. The script then runs under your own subdomain (e.g. 123456789.yourshop.com). Ad blockers and browser privacy settings are far less likely to block it.

Multiple top level domains? If you have more than one top level domain, create a separate Pixel datasource for each top level domain.

Chose Basic? Your tracking script appears right away. Skip to Step 3.


Step 2: Set up your DNS records (Domain Validated only)

  1. Enter your shop domain, without https:// and without www.

  2. Add the two DNS records Klar shows you (CNAME and CNAME IPv4) at your DNS provider.

  3. Click Verify DNS Records. Propagation usually takes a few hours, in rare cases up to 48 hours.

  4. Once both records show a green checkmark, copy the Tracking Script.

⚠️ GoDaddy, WebGo, All Inkl, Strato — common gotcha: These providers ask you to enter just the subdomain part in the "Name" field, not the full hostname. Strip your domain from the value Klar provides:

  • CNAME Name — Wrong: 123456789.yourshop.com → Right: 123456789

  • CNAME IPv4 Name — Wrong: 123456789-4.yourshop.com → Right: 123456789-4


Step 3: Add the base script in GTM

  1. In GTM, click Tags → New and choose Custom HTML.

  2. Paste the Klar tracking script.

  3. Set the trigger to All Pages (Page View).

  4. Name the tag Klar – Base Script and save.

Consent: fire the base script according to your consent setup, the same way as your other analytics tags.


Step 4: Create your variables

Create these as Data Layer Variables (Variables → New → Data Layer Variable). Adjust the paths to your data layer.

GTM variable

Value

Used in

DLV – Cart ID

your shop's cart ID, or the session ID variable

Add to Cart, Remove from Cart, Update Checkout, Order

DLV – Checkout ID

your shop's checkout ID, or the session ID variable

Update Checkout, Shipping Info, Payment Info

DLV – Order ID

your shop's order number

Order

DLV – Customer ID

your shop's customer ID (empty for guests)

Update Checkout, Order

DLV – Item ID

the product ID for your shop system (see table below). In GA4 format usually ecommerce.items.0.item_id

Product Viewed, Add to Cart, Remove from Cart

No cart or checkout ID? Use one session ID for both → Creating a session ID in Google Tag Manager.

Which product ID should I send?

The productId must be the same ID your shop system sends to Klar. Otherwise product views and cart actions can't be matched to your products and orders. Check what your data layer puts into item_id: it is often the SKU or a variant ID, which may not be the right one.

Shop system

Send as productId

Shopware 6

The product UUID of the item. For variants, the variant's UUID (in Shopware, a variant is a product with a parent).

Shopware 5

The article number. If it is empty, the article name.

WooCommerce

The variation ID for variable products, otherwise the product ID.

Oxid

The article OXID. For variants, the variant OXID.

BigCommerce

The product variant ID. If there is none, the product name.

Klar API

The productVariantId you send in your API payload. Required: without it, pixel events can't be matched to your API orders.


Step 5: Add the required events

Create one Custom HTML tag per event. Use a Custom Event trigger with the matching data layer event name.

Fire order matters. Each event tag must fire after the base script. Under Advanced Settings → Tag Sequencing, set Klar – Base Script to fire before the event tag.

Product Viewed

Trigger: view_item

<script>
window._k_q = window._k_q || [];
window._k_q.push(["Klar:sendProductViewedEvent", {
productId: "{{DLV – Item ID}}"
}]);
</script>

Add to Cart

Trigger: add_to_cart

<script>
window._k_q = window._k_q || [];
window._k_q.push(["Klar:sendAddToCartEvent", {
cartId: "{{DLV – Cart ID}}",
productId: "{{DLV – Item ID}}"
}]);
</script>

Update Checkout

Trigger: begin_checkout

<script>
window._k_q = window._k_q || [];
window._k_q.push(["Klar:sendUpdateCheckoutEvent", {
checkoutId: "{{DLV – Checkout ID}}",
cartId: "{{DLV – Cart ID}}",
customerId: "{{DLV – Customer ID}}"
}]);
</script>

Order

Trigger: purchase (order confirmation page)

<script>
window._k_q = window._k_q || [];
window._k_q.push(["Klar:sendOrderEvent", {
orderId: "{{DLV – Order ID}}",
cartId: "{{DLV – Cart ID}}",
customerId: "{{DLV – Customer ID}}"
}]);
</script>

Guest checkouts: leave customerId empty. Missing cartId or checkoutId? Use your session ID for both.

The orderId must match the order ID Klar receives from your shop system. Otherwise the order can't be matched to its customer journey.


Step 6: Add the recommended events

Same setup as Step 5: one Custom HTML tag per event, fired after the base script.

Remove from Cart

Trigger: remove_from_cart

<script>
window._k_q = window._k_q || [];
window._k_q.push(["Klar:sendRemoveFromCartEvent", {
cartId: "{{DLV – Cart ID}}",
productId: "{{DLV – Item ID}}"
}]);
</script>

Shipping Info

Trigger: add_shipping_info

<script>
window._k_q = window._k_q || [];
window._k_q.push(["Klar:sendShippingInfoEvent", {
checkoutId: "{{DLV – Checkout ID}}"
}]);
</script>

Payment Info

Trigger: add_payment_info

<script>
window._k_q = window._k_q || [];
window._k_q.push(["Klar:sendPaymentInfoEvent", {
checkoutId: "{{DLV – Checkout ID}}"
}]);
</script>

Step 7: Add optional events


Step 8: Test before you publish

  1. Click Preview in GTM and open your shop.

  2. Walk through a full journey: product page → add to cart → remove an item → checkout → shipping → payment → test order.

  3. In Tag Assistant, check that Klar – Base Script fires on every page and each event tag fires on its trigger.

  4. Open your browser's developer tools. Failed events show a descriptive error in the Console.

  5. When everything fires, click Submit and publish the container.


Step 9: Add the data privacy snippet

Add Klar's data privacy snippet to your privacy policy. You'll find it in the Klar Pixel datasource settings, below the tracking script, under Data Protection Snippet (German and English).


Step 10: Set up URL parameters in your ad accounts

To accurately match conversions and costs across channels, add Klar's tracking parameters to your ad URLs. Guides per channel:


What happens next?

Klar starts tracking right away. Attribution data appears in your reports from the next day, only from the moment the pixel went live, not retroactively. You can follow how your pixel coverage builds up over the next 30 days in the Action Centre → Overview.

🎉 That's it, your Klar Pixel is live.


Related Articles

Did this answer your question?