I don't know if this is the right place to ask but it is programming (in a way). How does the Google tag manager work?
The way I see it:
User interacts with the document (page):
How does this data from the dataLayer then get sent to Google Analytics, AdWords or other configured services? Which piece of code does this?
Is is possible that the tag that was responsible for pushing the event into the dataLayer also sends it to GA service? OR is there some other generic GA tag that picks up everything that was written into the DL and then sends it to the GA?
How do variables fit into this story? The way I see it it can be both written to a variable (a tag can store something into a pre-set up variable) or something can be pre-defined in a variable and used by the tag.
Thanks for any clariffication on this.
Tags are what send the data to analytics platform (GA or other). And the tag javascript snippet that talks to analytics platform resides within gtm.js
When we configure container through GTM UI, adequate tag (javascript code) gets added to gtm.js for your container. Every site owner who uses GTM gets a different gtm.js based on their configuration (that is the purpose of id parameter to gtm.js). Infact, https://www.googletagmanager.com/gtm.js will lead to 404.
You can try https://www.googletagmanager.com/gtm.js?id=YOUR_CONTAINER_ID as you add different tags and you can see different gtm.js files.
That's how tag management products achieve inserting code snippet within sites without needing any alterations to the actual site pages (beyond inserting the initial container tag related code, ofcourse).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With