Reputation: 336
<script>
dataLayer = [{
'pageCategory': 'signup',
'visitorType': 'high-value'
}];
</script>
Upvotes: 0
Views: 73
Reputation: 11
Here is a simple example of how to do it. Create a "Custom HTML tag" and insert in it:
<script>
dataLayer.push("documentTitle", document.title);
dataLayer.push("event", "documentTitleReady");
</script>
Now you can use this event to fire another tag that reads this dataLayer variable.
Upvotes: 0
Reputation: 2631
You can use a GTM variable that reads a global JavaScript variable on your page, yes. Then you can use that GTM variable in a custom HTML tag to push to the dataLayer. Make sure it also fires a "im-ready" event too though, so any dependent tags can wait for it to fire.
Upvotes: 1