I am no sure how to setup the dataLayer across iframes with the Google tag manager.
I found the following information:
Google Tag Manager dataLayer within iframes
On the website is the iFrame. The iFrame is loaded on an sudomain.
Parentpage: www.domain.com
iFrame: www.sudomain.domain.com
Is it correct to setup the GTM container on the parentpage and define all dataLayer variable there and push the dataLayer from the iFrame via the parent.dataLayer.push
method?
Does the parent.dataLayer.push
method then push the dataLayer values automatically to the dataLayer on the parentpage?
For example:
Parentpage
dataLayer = [{
'country': 'DE',
'pageType': 'product'
}]
Then the iFrame will be loaded with the parent.dataLayer.push
method:
parent.dataLayer.push({
'country': 'DE',
'pageType': 'product123' });
Will the dataLayer value for 'pageType' in the parentpage then automatically be overwritten by the iframe value)?
Thanks