Trying to achieve content grouping in mobile site which is SPA.
The scenario goes like this: When I am visiting a PDP page for the first time, category variable is set and this is sent to content groups in Universal Analytics Tag. If after this I go back to the homepage, the category variable doesn't update and homepage is also grouped under the same content group of previous PDP page.
This variable only updates when I visit another PDP page.
I am using a custom event PageLoad to mimic the pageView event. Just want the data layer varaibles to refresh within the consecutive PageLoad event.
Thanks
There is now a documented way to reset the data layer. See Reset in the Data layer docs.
If you push a function to the dataLayer
, it'll give you access to an object with get
, set
, and reset
semantics. For this question in particular, reset
is the relevant bit.
There's an undocumented way to cleanup the whole dataLayer using this method:
var gtm = window.google_tag_manager['GTM-XXXXXX'];
gtm.dataLayer.reset();
Now you don't necessarily need to do that since you can set the values you don't want anymore to undefined
in your dataLayer:
dataLayer.push({
'please_go_away': undefined
});
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