简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM