The data layer is a list of information that the site makes available for Google Tag Manager to read. Instead of Tag Manager having to guess a purchase value by looking at the page, the site hands over the information already organized: “a purchase happened, for R$350, order 1234.” Tag Manager reads it, and the GA4 or Google Ads tag sends the right data. It’s the piece that separates fragile measurement from reliable measurement.

People who’ve never heard of the data layer usually measure based on what shows up on screen: the button text, the URL of the thank-you page. That works until someone changes the button text or the page address. The data layer doesn’t break when that happens, because the information comes straight from the site’s own system.

How the data layer works

In the site’s code there’s a list called dataLayer. When something important happens, the site adds a message to that list using the dataLayer.push command. The message has an event name and, if needed, the data for that moment.

An example of a form submission:

dataLayer.push({ event: ‘generate_lead’, form_name: ‘quote’, lead_source: ‘site’ });

An example of a purchase:

dataLayer.push({ event: ‘purchase’, ecommerce: { transaction_id: ‘1234’, value: 350, currency: ‘BRL’ } });

Tag Manager listens to this list. When a message with the generate_lead event arrives, it fires the tags set up for that event and reads the other fields as variables.

What to do in Google Tag Manager

  1. Create the trigger. A Custom Event trigger, with the exact name of the event sent by the site (generate_lead, for example). The name needs to match exactly, including upper and lower case.
  2. Create the variables. For each piece of data you want to use, a Data Layer Variable with the field’s name (form_name, value).
  3. Use them in the tags. In the GA4 event tag, the event name and the parameters. In the Google Ads conversion tag, the value and the currency.
  4. Test in Preview mode. Submit the test form and watch, in Tag Assistant, the message arrive in the data layer and the tags fire. See how to test with Tag Assistant.

When the data layer is worth using

  • Purchases and values. The order value, the currency, the products. This is what lets Google Ads optimize for revenue, not just the number of sales.
  • Forms that don’t change page. A form that shows “submitted successfully” without going to a thank-you page has no URL to measure. The push solves that.
  • Information that doesn’t show on screen. The plan chosen, the type of customer, the order ID to cross-reference with your CRM.
  • Sites with frequent changes. Measurement stops depending on the button text and the page’s appearance.

Who does what

The push in the code is the job of the site developer or the store platform. Many e-commerce platforms and plugins already send the purchase data layer in GA4’s standard format. The setup in Tag Manager (triggers, variables and tags) is the job of whoever handles measurement.

The best results come from a written agreement: a list with the name of each event, when it happens, and which fields it carries. The developer implements it, whoever handles measurement sets it up, and they test it together.

Event names

Use Google’s recommended names when they exist: generate_lead for contact, purchase for a sale, begin_checkout for the start of checkout, sign_up for sign-up. GA4 and Google Ads recognize these names, and the built-in reports work better with them. More on this in GA4 events.

Common mistakes

  • Push happening before Tag Manager loads, without the list created beforehand. The line window.dataLayer = window.dataLayer || []; at the top of the page avoids this problem.
  • Event name different between the site and the trigger. “Generate_Lead” and “generate_lead” are not the same event.
  • Value sent as text. “R$350.00” is not a number. Send 350 and the currency separately.
  • Purchase sent twice when someone reloads the confirmation page. Use the order ID so Google can discard the duplicate.

Frequently asked questions

Do I need a developer to use the data layer? To create the push on the site, usually yes, or a platform that already sends it. The Tag Manager part doesn’t require coding.

Does the data layer work without Tag Manager? The list exists on the site, but it’s Tag Manager that reads it and turns it into tags. See what Google Tag Manager is.

Does the data layer store personal data? Only what the site puts into it. Don’t send names, emails, or phone numbers in plain text to analytics tools.

Want the data layer designed for your site? Ciclicko hands the developer the list of events, sets up Tag Manager, and tests it. Check out our conversions and CRM service.