GA4 ecommerce guide: DataLayer and Google Tag Manager

By Martín Garay

Measuring a store in GA4 means the site publishes, in a data layer, one event for each step of the purchase journey, with the correct products and amounts, and Google Tag Manager sends them to GA4. This guide is the map; each topic has its own article.

It is written for those who decide what to measure, not only for those who implement it. Technical terms are explained in plain words and the detail appears under the label "For the technical team". CookingMetrics offers audits and support to development teams and does not sell tools or implement stores. A warning: the Google pages consulted on November 16, 2026 show no update date; it is worth rereading them before implementing.

In summary

  • The data layer (dataLayer) is a list of messages that the site prepares and that Google Tag Manager reads in order to send them to GA4.
  • Each step of the journey has an event: viewing a list, choosing a product, viewing it, adding it, paying, buying.
  • Products travel in a list called items; amounts need a currency.
  • Event and parameter names must be Google's. If they are invented, some reports do not recognize them.
  • Events are validated before publishing and audited from time to time: a badly sent event does not produce an error, it produces false data.
  • This guide does not promise that measuring better will increase sales; it lets you know what is happening.

What problem it solves

Without measuring the journey, a store knows how much it sold but not where people drop off: on the home page, on the product page, in the listing, in the search or at payment. GA4 can show that journey if the site hands it the right events. Measuring it well is a business and product decision before a technical one: what you want to know, from which pages, and who is responsible for keeping the data correct.

The journey and its events

An event is a message that signals that something happened: "a person viewed this product". These are the GA4 commerce events according to the official documentation, grouped by stage, with the article where each one is developed:

You do not need to implement them all at once. A reasonable order, and it is our own criterion, is to start with purchase and the payment steps, because without them there is no revenue to look at, and then work backward to the product page, the listing and the home page.

What data each event carries

Almost all commerce events carry a list of products (items) and, if there are amounts, the currency (currency) and the value (value). According to Google (reference), currency is required if value is sent. Each product needs at least an identifier or a name; Google recommends sending both. The price (price) is the unit price with the discount already applied, and the discount goes separately in discount.

A decision maker does not need to memorize parameters; they do need to know that every missing piece of data is a gap in a report. If the site does not send the product category, GA4 cannot show sales by category.

How events reach GA4

The site publishes the event in the data layer and Google Tag Manager sends it to GA4. There is another way, sending the event directly with gtag.js. In his guide, Martín Garay prefers the data layer with Tag Manager, and it is a matter of judgment, not a requirement: the advantage is that the development team and the analytics team agree on a data contract, and changing a tag does not force you to touch the site's code.

For the technical team: a minimal example of an event published in the data layer.

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null });
window.dataLayer.push({
  event: "view_item",
  ecommerce: {
    currency: "USD",
    value: 40.0,
    items: [{ item_id: "SKU-001", item_name: "Taza de cerámica", price: 40.0, quantity: 1 }]
  }
});
  • The first push line clears the previous ecommerce object. It is a widespread practice so that data from one event is not mixed with data from the previous one; we did not find it in the official pages consulted.
  • In Tag Manager, a common approach is one trigger per event and one GA4 event tag that reads ecommerce from the data layer.
  • Event and parameter names must be exactly Google's.
  • The data layer should be declared before the Tag Manager container loads.

How to validate

Before publishing, go through the store as a customer would and check, event by event, that it is sent, that it carries the correct products and that the amounts add up. Martín Garay's original guide uses two Chrome extensions for this: Tag Assistant Companion and Simple Data Layer Viewer. After publishing, compare the purchase total in GA4 with that of the store's order system: they may not match exactly, but a large difference indicates a problem.

For the technical team: check that transaction_id is unique, that value is the sum of price times quantity without shipping or taxes, that currency is always present and that there are no duplicate events caused by page reloads.

A detail Google does not define: the index

In listings, each product can carry an index with its position. Google describes it as the position of the product in a list and does not say whether it is counted from 0 or from 1; its code examples use both. Choose a base, document it and use it in all lists, or position reports will not be comparable.

Limits and risks

  • There is no guarantee of results. Measuring well does not increase sales by itself.
  • A measurement error gives no warning. A misspelled parameter does not produce a visible error; it produces an incomplete report.
  • The official pages have no date. It is worth rereading them before implementing.
  • This guide does not replace an audit. Each store has its own platform, its own checkout flow and its own exceptions.
  • Consent and privacy: what can be measured depends on the visitor's consent and on the applicable regulations; this guide does not cover them.

What to do next

Choose a single stage of the journey, the one that raises the most questions for you today, and read its article. If you would like us to review with your team what is measured today and what data is missing, see our Google Analytics audit service: we audit and support, and we do not implement stores or sell tools.

Frequently asked questions

What is the data layer (dataLayer)?

It is a list of messages that the site prepares and that Google Tag Manager reads in order to send them to GA4. It lets the site and analytics agree on what is measured.

Do I have to implement all the ecommerce events?

No. It is best to start with the purchase and the payment steps, and work backward to the product page, the listing and the home page according to what you need to know.

Can I use my own event names?

For commerce events, use Google's names. With custom names, some commerce reports do not recognize them. For particular needs, additional events can be defined.

How do I know if my measurement is correct?

Go through the store and check each event with debugging tools, and compare the purchases in GA4 with those in the order system. A large difference indicates a problem.

Contents

Would you like to review what is measured in your store today?

Book my GA4 audit