title: Google tag manager data layer within iframes
body: <p>I am no sure how to setup the dataLayer across iframes with the Google tag manager.<br>
  I found the following information:
  <a href="https://stackoverflow.com/questions/22382182/google-tag-manager-datalayer-within-iFrames">Google Tag Manager dataLayer within iframes</a></p>
  
  <p>On the website is the iFrame. The iFrame is loaded on an sudomain.</p>
  
  <blockquote>
    <p>Parentpage: www.domain.com</p>
    
    <p>iFrame: www.sudomain.domain.com</p>
  </blockquote>
  
  <p>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 <code>parent.dataLayer.push</code> method?</p>
  
  <p>Does the <code>parent.dataLayer.push</code> method then push the dataLayer values automatically to the dataLayer on the parentpage?</p>
  
  <p>For example:</p>
  
  <p>Parentpage</p>
  
  <pre><code>dataLayer = [{
          'country': 'DE',
          'pageType': 'product'
      }]
  </code></pre>
  
  <p>Then the iFrame will be loaded with the <code>parent.dataLayer.push</code> method:</p>
  
  <pre><code>parent.dataLayer.push({
          'country': 'DE',
          'pageType': 'product123'    });
  </code></pre>
  
  <p>Will the dataLayer value for 'pageType' in the parentpage then automatically be overwritten by the iframe value)?</p>
  
  <p>Thanks</p>