3

I need to track my page views using GTM code in Angular 6 application. Pasted below line of code in Index.html page and my value for Prod_GTM_ID will change based on different environments.

To get dynamic values, as mentioned(3rd answer) in URL How to use environment variable in index.html for Angular 6, I followed the steps but using {{Prod_GTM_ID}} shows error 'Property assignment expected.(undefined)'

<script>(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'?'&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',{{Prod_GTM_ID}});</script>

How to import environment variables inside index.html page. Is there any simplest approach to achieve the same.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.