Jordan Mack
Jordan Mack

Reputation: 8763

How does Google Tag Manager extract tracking data from dataLayer?

Google Tag Manager provides the dataLayer global variable for storing event tracking information. To add a new event, you simply do a dataLayer.push({"Your data here"});, and the information is captured.

How is the information from that array being sent back to Google? Is there some kind of polling of that variable going on in the background?

Upvotes: 3

Views: 1014

Answers (1)

Eduardo
Eduardo

Reputation: 22832

This information is not being sent to Google. Everything in Google Tag Manager is evaluated client side.

You publish your Container that includes rules based in Events. Once this container is loaded into the browser that also loads all the tags, rules and macros defined on GTM UI.

When the container is loaded the dataLayer array is evaluated and replaced by an API that evaluates calls to the push method right away. This is not a common Array anymore but a custom object defined by the GTM Javascript code.

Once the push is evaluated by GTM code, it's matched to the several rules defined on the Container. Note that this doesn't reach Google again it's evaluated client side.

At least this is how it works right now. Since it's not documented I assume it can change in the future.

Upvotes: 5

Related Questions