Skip to main content

How to Set Up the Data Layer Correctly

Learn how to correctly set up the add_to_cart and purchase events in the data layer so Tanganica can accurately measure orders and optimise your ads.

Written by Saša Kučerová

For Tanganica to correctly measure orders and optimise ads, it needs not only the tracking code but also a correctly configured data layer (Data Layer). The data layer passes information to the system about what customers are doing in your store, what they have added to their cart, and what they have ordered.

If the data layer is not set up correctly, campaigns will not have accurate data and cannot optimise properly.

The add_to_cart event

This event tracks when a customer adds a product to their cart. It is not mandatory, but it helps the campaign find interested customers more quickly before they make a purchase. We recommend implementing it.

gtag("event", "add_to_cart", {
  currency: "EUR",
  value: 30.03,
  items: [
    {
      item_id: "SKU_12345",
      item_name: "Product Name",
      item_brand: "Brand",
      item_category: "Category",
      price: 10.01,
      quantity: 3
    }
  ]
});

The purchase event

This event is mandatory. Without it, we cannot launch campaigns. It tells the system that a customer has completed an order and is the primary signal for ad optimisation.

The event must be placed on the order confirmation page — the page the customer sees after a successful purchase.

gtag("event", "purchase", {
  transaction_id: "T_12345_1",
  value: 30.03,
  tax: 4.90,
  shipping: 5.99,
  currency: "EUR",
  items: [
    {
      item_id: "SKU_12345",
      item_name: "Product Name",
      item_brand: "Brand",
      item_category: "Category",
      price: 10.01,
      quantity: 3
    }
  ]
});

How to correctly fill in the order value

This is where most stores make a mistake. The purchase event has three separate fields for different parts of the price, and each must contain the correct amount:

  • value — revenue excluding shipping and tax

  • shipping — shipping cost separately

  • tax — tax separately

If you include shipping or VAT in the value field, the system will double-count them in reports and order values will appear higher than they actually are.

Important notes

  • Use a decimal point, not a comma (correct: 1000.00, incorrect: 1000,00).

  • Enter the currency using the international standard abbreviation (EUR for euros, CZK for Czech crowns).

If you are unsure about the setup, contact our customer support. We are happy to help you with the implementation.

Did this answer your question?