title: Angular2 using different GTM containers according to environments
body: <p>I'm using google tag manager(GTM) to manage tags in the angular application like this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html lang="en"&gt;
    &lt;head&gt;
      &lt;base href="/"&gt;
      &lt;title&gt;Angular Tour of Heroes&lt;/title&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;!-- Google Tag Manager --&gt;
      &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-WAHOCA');&lt;/script&gt;
      &lt;!-- End Google Tag Manager --&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;!-- Google Tag Manager (noscript) --&gt;
      &lt;noscript&gt;&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WAHOCA"
        height="0" width="0" style="display:none;visibility:hidden"&gt;&lt;/iframe&gt;&lt;/noscript&gt;
      &lt;!-- End Google Tag Manager (noscript) --&gt;
      &lt;my-app&gt;Loading...&lt;/my-app&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now I'd like to use different GTM containers according to the environments, like development, production environment and so on. The above code is just using the 'GTM-WAHOCA' container ID by hardcoding.<br>
  How can I configure to use different GTM containers according to the environments in the index.html? That means I want to mangage the GTM container IDs conveniently in the file. Or, are there other ways to achieve my requirements?</p>
  
  <p><strong>References:</strong><br>
  1.<a href="https://github.com/angular/angular-cli/issues/4451#issuecomment-285026543" rel="nofollow noreferrer">Is there a way to conditionally include scripts in index.html as in analytics?</a><br>
  2.<a href="https://github.com/angular/angular-cli/issues/1544#issuecomment-237421098" rel="nofollow noreferrer">Conditional template logic in index.html for beta.11-webpack</a><br>
  3.<a href="https://github.com/angular/angular-cli/issues/4288#issuecomment-277524841" rel="nofollow noreferrer">Feature Request: load scripts in angular-cli.json conditionally?</a></p>