title: Google Tag Manager - (enhanced) e-commerce - how to load Javascript after <body> tag
body: <p>I'm still learning Google Tag Manager and Enhanced E-commerce tracking, but I have a few questions, some of which may be pretty basic:</p>
  
  <ol>
  <li>We're using a site on a third party system - I already have Google Tag Manager in my template within the <B>HEAD</B> tag, working with Universal (Google) Analytics. However, we want to just get the e-commerce transaction (purchase) data into Analytics - so basic e-commerce tracking would be fine, but I'd rather use <B>Enhanced E-commerce</B> tracking since it is newer - even though my immediate requirement is just to track purchases.</li>
  </ol>
  
  <p>So, I need to send push transaction data into the dataLayer, but I can't do this due to restrictions on the system. I can only add special Javascript code to the end of the <B>BODY</B> tag for my "checkout complete" page. </p>
  
  <p>Reading this online, the dataLayer must be defined in the <B>HEAD</B> before the GTM code is in place. As I cannot do that, I need to load the data using Javascript at the end of <B>BODY</B>.</p>
  
  <p>Is this possible, if so how? I think I can do this using a Custom Javascript Variable as mentioned here: <a href="https://developers.google.com/tag-manager/enhanced-ecommerce#macro" rel="nofollow noreferrer">https://developers.google.com/tag-manager/enhanced-ecommerce#macro</a></p>
  
  <ol start="2">
  <li><p>Is a "macro" the same as a "variable" as explained in the above link? It says "macro", but Google Tag Manager allows me to define a custom "variable" which is "Custom Javascript". Just checking that these are one in the same.</p></li>
  <li><p>Where would this code actually "run", if I put it in Google Tag Manager? The third party system defines some variables for me during script execution and I don't know where/when (during page load of the checkout thank-you page) it does it, so to be safe, I'd rather have this script run at the end of the page before the <B>BODY</B> tag closes - if I were doing this manually using plain Javascript within the HTML. In Tag Manager, how would I tell the Javascript to run "at the end of the page"? </p></li>
  </ol>
  
  <p>Thanks in advance!</p>