Google Tag Manager

GTM Ecommerce Tracking: One dataLayer for GA4, Meta, TikTok and Snap

The ecommerce dataLayer pushes from product view to purchase, the parameters each step needs, and how one push feeds GA4, Meta, TikTok and Snap tags with one transaction ID and event ID.

Cover: One push, four pixels. a product page, cart, checkout and order confirmation in a row, each sending one dataLayer push that branches into GA4, Meta, TikTok and Snap tags.

The usual way ecommerce tracking breaks is not GTM. It is a site that pushes different shapes at each step, a purchase that fires before payment, or an item ID that changes between the product page and the cart. If the dataLayer is clean, the GTM side is mostly copying the same trigger and variables into four tags.

The ecommerce events, step by step

Copy this

Funnel steps, parameters and platform names

 Push whenParametersMetaTikTokSnap
view_itemThe product page has loadedcurrency, value, itemsViewContentViewContentVIEW_CONTENT
add_to_cartThe cart confirms the addcurrency, value, itemsAddToCartAddToCartADD_CART
begin_checkoutCheckout openscurrency, value, items, couponInitiateCheckoutInitiateCheckoutSTART_CHECKOUT
add_payment_infoA payment method is chosencurrency, value, payment_type, itemsAddPaymentInfoAddPaymentInfoADD_BILLING
purchasePayment is confirmedtransaction_id, currency, value, tax, shipping, items, event_idPurchasePurchasePURCHASE

Google’s list has more steps (view_item_list, select_item, view_cart, remove_from_cart, add_shipping_info, refund and the promotion events), and they are worth adding for GA4 reports. For the ad platforms, the five above carry the optimization. Each item needs item_id or item_name; send both, plus price and quantity.

One sample purchase push

This is the shape to hand your developer. The first line clears the previous ecommerce object, which is what Google’s GA4 ecommerce guide does before every push, so values from an earlier step don’t leak into this one.

window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null }); // clear the previous ecommerce object
dataLayer.push({
  event: 'purchase',
  event_id: 'ord-10482-purchase',  // one ID per event; the server reuses it
  ecommerce: {
    transaction_id: '10482',        // the order ID, never empty
    value: 249.00,                  // number: price x quantity, no tax or shipping
    currency: 'USD',
    tax: 12.45,
    shipping: 15.00,
    coupon: 'WINTER10',
    items: [{
      item_id: 'SKU-123',           // the same ID as in your product catalog
      item_name: 'Running shoe',
      item_category: 'Shoes',
      price: 124.50,
      quantity: 2
    }]
  }
});

Reuse one push for every platform

How to

Wire one ecommerce push to GA4, Meta, TikTok and Snap in GTM

Build once, then copy the trigger and variables into each platform’s tag.

  1. 01

    Create one trigger per step

    Custom Event triggers named after each event: purchase, add_to_cart and so on.

  2. 02

    Create the shared variables

    Data Layer Variables for ecommerce.transaction_id, ecommerce.value, ecommerce.currency, ecommerce.items and event_id.

  3. 03

    GA4

    A Google Analytics: GA4 Event tag with Event Name set to {{Event}}. Under More Settings, Ecommerce, tick Send Ecommerce data with Data Source set to Data Layer. Attach all five triggers.

  4. 04

    Meta

    The Meta Pixel template reads the latest ecommerce object for content and value. Set the event name per tag and Event ID to {{DLV - event_id}}.

  5. 05

    TikTok

    The TikTok Pixel template can read GA4 ecommerce dataLayers for product properties. Set Event ID to the same variable.

  6. 06

    Snap

    Map price from value, currency, item IDs and number of items, transaction ID on PURCHASE, and Client Deduplication ID from event_id.

  7. 07

    Test the full path

    In Preview, buy something with a test payment, and check each tag fired once with the same transaction ID and event ID.

Event IDs and dedup rules per platform are in Meta Pixel and Conversions API in GTM and TikTok and Snap pixels in GTM.

transaction_id: the field that stops double purchases

In GA4, the transaction ID is what lets Google Analytics deduplicate repeat purchases from the same user. Google warns against sending an empty string, because every purchase with transaction_id set to empty is deduplicated together. In Google Ads, a second conversion with the same conversion action and transaction ID is dropped. Snap matches the Pixel’s transaction_id to the server’s order_id for purchases. One field, used three ways, so it must be the real order ID and never blank.

If GA4 already shows duplicate transactions, GA4 duplicate purchases walks through finding the cause.

Where this goes wrong

  • Purchase fires before payment. Some sites push purchase when the order is created, then send the buyer to a payment page they may abandon. Push on the confirmation page, after the payment status is checked.
  • Online payments never come back. Card and instalment payments that redirect to an external gateway and never return to a tracked page leave only cash orders tracked. Ask for a return URL that confirms payment.
  • Item IDs that change. A SKU on the product page, an internal number in the cart, and a number instead of a string at checkout break catalog matching. One ID, one type, everywhere.
  • Stale values. Without the ecommerce: null line, a variable can read the previous step’s items.
  • Text values and the wrong currency. "249,00 USD" is text. Local-currency amounts labelled as USD inflate revenue.
  • A store app and GTM both sending purchase. A platform plugin and your GTM tags can both send the same purchase. Pick one source per platform.

Do it faster with Whathead

With Whathead’s Google Tag Manager MCP, Claude can read your container and tell you which ecommerce events each platform receives, which tags lack a transaction ID or event ID, and then build the missing triggers, variables and tags in a workspace. The GA4 MCP can run a funnel report afterwards to see whether each step is arriving. Whathead is our product.

  • “In GTM-XXXXXXX, make a table of the ecommerce events (view_item to purchase) and which GA4, Meta, TikTok and Snap tags fire on each. Mark gaps and any tag without a transaction ID or event ID.”
  • “Create Custom Event triggers for the five ecommerce events and Data Layer Variables for transaction_id, value, currency, items and event_id. Don’t publish; list the workspace changes.”

Before anything changes, Claude asks you to approve each GTM write. There is no dry-run preview for GTM; the workspace holds the changes until you test them in Preview and publish a version.

GTM ecommerce tracking: common questions

How do I set up ecommerce tracking in GTM for GA4?

Have the site push GA4 ecommerce events to the dataLayer, create a Custom Event trigger for each, and add a GA4 Event tag with Send Ecommerce data enabled and Data Source set to Data Layer.

Why clear the ecommerce object before each push?

So values from an earlier push, such as items from a product list, don’t carry into the next event. Google’s GA4 ecommerce guide pushes ecommerce: null before each event.

Why is my GA4 purchase firing twice?

Common causes are a reload of the confirmation page, a gateway returning in a new tab, or a plugin and GTM both sending it. A real transaction ID lets GA4 deduplicate repeats from the same user.

Can one dataLayer push feed GA4 and the Meta Pixel?

Yes. The same Custom Event trigger and variables can fire GA4, Meta, TikTok and Snap tags; only the event names and field names differ per platform.

Do I need a developer for ecommerce tracking?

For the dataLayer pushes, yes, or a platform plugin that writes them. The GTM side can be built by a marketer once the pushes are reliable.

Sources

Written by Ahmed Shahin, founder of Whathead. Last reviewed 19 November 2026.