File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,16 +124,7 @@ function generateGoogleAnalytics() {
124124 if ( devMode || ga === undefined || ga === "" ) {
125125 return "''" ;
126126 }
127- return `'
128- <script async src=\\"https://www.googletagmanager.com/gtag/js?id=${ ga } \\"></script>
129- <script>
130- window.dataLayer = window.dataLayer || [];
131- function gtag() {
132- window.dataLayer.push(arguments);
133- }
134- gtag(\\"js\\", new Date());
135- gtag(\\"config\\", \\"${ ga } \\", {\\"anonymize_ip\\": true});
136- </script>
137- '` . replaceAll ( "\n" , " " ) ;
138- // Result must be a one-liner else we get compilation error.
127+
128+ // we return only the GA env variable, the rest is handled in the template file
129+ return `'{ga}'` ;
139130}
Original file line number Diff line number Diff line change 11< script type ="module " src ="./assets/scripts/cookieconsent-config.js "> </ script >
2- < script
3- type ="text/plain "
4- data-category ="analytics ">
5- @googleAnalytics ( )
6- </ script >
2+ < script type ="text/plain " data-category ="analytics ">
3+ window . dataLayer = window . dataLayer || [ ] ;
4+ function gtag ( ) {
5+ window . dataLayer . push ( arguments ) ;
6+ }
7+ gtag ( "js" , new Date ( ) ) ;
8+ gtag ( "config" , "@googleAnalytics()" , { "anonymize_ip" : true } ) ;
9+ </ script >
10+ < script type ="text/plain " data-category ="analytics " async
11+ src ="https://www.googletagmanager.com/gtag/js?id=@googleAnalytics() "> </ script >
You can’t perform that action at this time.
0 commit comments