I want to create data layer for Google Tag Manager which will be a script with dynamic data in body section of all pages.
Can anyone please explain how can we implement it(through SitePageData etc) with an example.
Thanks in advance.
Put the script in your layout view and populate the values from your model or logic, e.g:
window.dataLayer = window.dataLayer||;
On the same topic...
I would like to push to the datalayer for Google Tag Manager when a visitor visits a specific page, but the issue is the push needs to come before the GTM container.
Since it is only for a specific type of page I can not place it in the head of global Layout-file.
Now I am wondering, how do I manage to get the push before the GTM container loads on the page?
Thanks in advance!