title: Migrating from GA to GTM - which tracking codes are needed?
body: <p>I'm not sure which tracking codes are needed to get both Google Analytics (GA) and Google Tag Manager (GTM) to work. I'm currently using the following script with GA -></p>
  
  <pre><code>&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'UA-xxx-x');
  &lt;/script&gt;
  </code></pre>
  
  <p>Now that I'm setting up GTM, it is asking me to add the following tracking codes as well -></p>
  
  <pre><code>&lt;script&gt;(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-xxx');&lt;/script&gt;
  
  
  &lt;noscript&gt;&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-xxx"
  height="0" width="0" style="display:none;visibility:hidden"&gt;&lt;/iframe&gt;&lt;/noscript&gt;
  </code></pre>
  
  <p>Do I need all these snippets? It would be important to be able to both set up event tracking and not lose any previous GA data.</p>