title: "dataLayer.push" or declare with "dataLayer =" for Analytics Ecommerce Tracking GTM
body: <p>Which of these is more optimal?</p>
  
  <p>I have a thank-you page, and I need to load all of my transaction sale info into this page to post it to Google Analytics through Google Tag Manager.</p>
  
  <p>Do I declare the dataLayer using the code below and post it before my GTM code?</p>
  
  <pre><code>dataLayer = [{
    'ecommerce': {
      'purchase': {
        'actionField': {
          'id': '40008',
          'revenue': '90.00',
        },
        'products': [{
          'name': 'Clothes',
          'price': '9.00',
          'category': 'Shirt',
          'quantity': 10.00,
         }]
      }
    }
  }];
  </code></pre>
  
  <p>or do I push the data into the dataLayer which is created automatically and post it after my GTM code?</p>
  
  <pre><code>dataLayer.push({
    'ecommerce': {
      'purchase': {
        'actionField': {
          'id': '40008',
          'revenue': '90.00',
        },
        'products': [{
          'name': 'Clothes',
          'price': '9.00',
          'category': 'Shirt',
          'quantity': 10.00,
         }]
      }
    }
  });
  </code></pre>
  
  <p>What is the difference?  I will take the data from the dataLayer to Google with a "DOM Ready" event.</p>