Skip to content
DocsSearch the docsEnglishBack to siteOpen console

Google Tag Manager and the dataLayer

If your website already pushes GA4 e-commerce events to its dataLayer (Google Tag Manager, gtm4wp on WordPress, or gtag.js), one checkbox lets AdPix read them, so the funnel appears without writing a line of data stream. It is off by default.

What it does#

Sites that run Google Tag Manager push their shoppers' actions into a page array called the dataLayer: view_item when a product is opened, add_to_cart when it is added, and so on. With this option on, AdPix loads a small extra file (/dl.js) that listens to that array and passes the e-commerce events on through the normal AdPix e-commerce call. That means consent, the visitor's identity, attribution, duplicate protection and the product table all work exactly as they do for events you send yourself. The file stores nothing and sets no cookie.

It is off for every data stream until you tick it, and while it is off tracking works exactly as before.

Turn it on#

Open Admin → Data streams and click the data stream. In the Events card you will find Read e-commerce events from Google Tag Manager (dataLayer).

1
Tick the box. The settings panel opens; nothing is saved until you click Turn on.
2
Under Purchases come from, choose Server or dataLayer.
3
Check Events to forward. An event the website already sends another way is unticked, with a warning beside it; leave it that way.
4
To be sure first, tick Test first (count nothing) under Advanced.
5
Click Turn on. If the website sits behind a page cache, purge the cache once, then check the funnel the next day.

To go back, untick the box. It saves at once, and visitors pick the change up within a minute.

Test first#

With Test first, AdPix only reports which events the dataLayer carries (as dl_observe telemetry) and counts nothing. Telemetry is labelled as such in event origin and never counts as an e-commerce event. After a few days open Settings: the Seen in the last 7 days table lists each dataLayer event next to what the website already sends directly. When the numbers look right and purchases carry transaction IDs, untick Test first and click Save.

Counting each action once#

Each shopper action should come from one source only. For every event name AdPix checks whether the website sent it another way in the last 30 days, and leaves that name unticked. These are the common cases:

Website Funnel events Purchases
No dataLayer option off; as before as before
WordPress with the AdPix plugin and gtm4wp the dataLayer Server (the plugin reports orders)
Any site with Google Tag Manager and a server-side order feed the dataLayer Server
Any site with Google Tag Manager and no server path the dataLayer dataLayer
A site that sends view_item itself with ap('ecommerce', …) the rest from the dataLayer; view_item stays direct as you choose
Measurement change

Turning counting on or off, or changing Purchases come from while it is on, records a "tracking change" activity on that day. Lift and the Marketing Mix Model use it to know when measurement changed. Switching on a Monday, at the start of the day, keeps the comparison clean.

Limits#

  • The bridge reads the array you name once. If the website replaces the whole dataLayer object after load, later pushes are not seen.
  • Two AdPix tags on one page share one bridge, the last one registered.
  • If the website starts sending an event another way after you turned this on, AdPix does not untick it for you; check Settings again after a change to the site.
  • Custom dataLayer events, user identity and the older Universal Analytics shapes are not read.

Frequently asked questions#

Will turning this on change my numbers?

Not while it is unticked; tracking works exactly as before and no extra file is loaded. Once you turn it on, the funnel events from the dataLayer are added. Events the website already sends another way start unticked, so nothing is counted twice.

Which events are forwarded?

By default view_item, add_to_cart and begin_checkout, the same names AdPix already uses. You can add view_cart, remove_from_cart, add_shipping_info, add_payment_info, view_item_list, select_item, view_promotion, select_promotion and add_to_wishlist. Purchases follow the "Purchases come from" setting alone.

Why do some events start unticked?

Because the website sent the same event another way in the last 30 days (a direct ap('ecommerce', …) call, a plugin or the server). Ticking it would count each one twice. Tick it only once the other source is gone.

Should purchases come from the server or the dataLayer?

From the server whenever your website can send them. A server purchase carries the order number and survives ad blockers and closed tabs. Choose dataLayer only when the website has no server path; if both send purchases, each order is counted twice, and the panel warns you. AdPix preselects Server when the website already has server-side purchases.

My dataLayer has another name. Can I change it?

Yes. Under Advanced, set the variable name (letters, digits, _ or $, up to 64 characters). On WordPress it is the gtm4wp setting "dataLayer variable name".

Does it work with the consent banner?

Yes. Events go through the same gate as every other event, so without statistics consent they are dropped exactly like a manual call, and the opt-out cookie is honoured.

Build with the APIUnderstand where revenue comes from.
Was this page helpful?