Currently, I am using Angular and I am encountering an issue while attempting to utilize an environment variable in my index.html for Google Analytics. I have attempted the following approach:
<script>
import {environment} from "./environments/environment";
</script>
<!-- End Google Tag Manager (noscript) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=" + environment.googleAnalytics></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', environment.googleAnalytics);
</script>
Unfortunately, I am facing an issue with concatenation in the script link. Could you please assist me? Specifically, the concatenation section
https://www.googletagmanager.com/gtag/js?id=" + environment.googleAnalytics
is not functioning as expected.