title: dataLayer.push not working after GTM script
body: <p>I want to implement the Enhanced Ecommerce with Google Tag Manager and I want to push some data for the tag Universal Analytics.</p>
  <p>I have always created the dataLayer before the GTM script, but now I need to send more data with <code>dataLayer.push</code></p>
  <p>And it doesn't work, <code>datalaLayer.push</code> only works if it happens just before the GTM script starts.</p>
  <p>Example. This works:</p>
  <pre><code>   &lt;script&gt;
      &lt;head&gt;
       dataLayer = [{   
                   
              'google_tag_params': {
                 'ecomm_pagetype': 'category',
                 'ecomm_category': '{{ $resource-&gt;seo-&gt;h1 }}',
               }
           }];
      
      dataLayer.push({
                'ecommerce': {
                  'currencyCode': 'EUR',    
                  'impressions': [
                       {
                          'id':       '12312',
                          'price':    24,
                          'category': 'wfwefwerwerwer',
                          'position': 2,
                          'name':     'wfwefwerwerwer',  
                          'brand':   'My Brand',
                          'list':    'Product List',
      
                      }
                  ]
                }
              });
      
      (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
      new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
      j=d.createElement(s),dl=l!='dataLayer'?'&amp;l='+l:'';j.async=true;j.src=
      'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
      })(window,document,'script','dataLayer','GTM-XXXXXX');
      
      &lt;/script&gt;
      &lt;/head&gt;
  </code></pre>
  <p>But if I use dataLayer.push after the GTM script does not work, no data is sent and no errors are reported.</p>
  <p>This isn't working for me:</p>
  <pre><code>&lt;head&gt;
      &lt;script&gt;
           dataLayer = [{   
                       
                  'google_tag_params': {
                     'ecomm_pagetype': 'category',
                     'ecomm_category': '{{ $resource-&gt;seo-&gt;h1 }}',
                   }
               }];
          
          
          (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
          new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
          j=d.createElement(s),dl=l!='dataLayer'?'&amp;l='+l:'';j.async=true;j.src=
          'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
          })(window,document,'script','dataLayer','GTM-XXXXXX');
  
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
      //something content html here
  
      &lt;footer&gt;&lt;/footer&gt;
  
      &lt;script&gt;
          dataLayer.push({
            'ecommerce': {
              'currencyCode': 'EUR',    
              'impressions': [
                   {
                      'id':       '12312',
                      'price':    24,
                      'category': 'wfwefwerwerwer',
                      'position': 2,
                      'name':     'wfwefwerwerwer',  
                      'brand':   'My Brand',
                      'list':    'Product List',
  
                  }
              ]
            }
          });
      &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>