mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
50479: Google analytics only loaded when tracking id present
This commit is contained in:
@@ -10,12 +10,6 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<script>
|
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
||||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
|
||||||
</script>
|
|
||||||
<ds-app></ds-app>
|
<ds-app></ds-app>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
@@ -10,12 +10,6 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<script>
|
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
||||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
|
||||||
</script>
|
|
||||||
<ds-app></ds-app>
|
<ds-app></ds-app>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
@@ -25,14 +25,25 @@ export function main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add google analytics key
|
addGoogleAnalytics();
|
||||||
const script = document.createElement('script');
|
|
||||||
script.innerHTML = 'ga(\'create\', \'' + ENV_CONFIG.gaTrackingId + '\', \'auto\');';
|
|
||||||
document.body.appendChild(script);
|
|
||||||
|
|
||||||
return platformBrowserDynamic().bootstrapModule(BrowserAppModule);
|
return platformBrowserDynamic().bootstrapModule(BrowserAppModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addGoogleAnalytics() {
|
||||||
|
// Add google analytics if key is present in config
|
||||||
|
const trackingId = ENV_CONFIG.gaTrackingId;
|
||||||
|
if (trackingId !== '' && trackingId !== null) {
|
||||||
|
const keyScript = document.createElement('script');
|
||||||
|
keyScript.innerHTML = `(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');`
|
||||||
|
+ 'ga(\'create\', \'' + ENV_CONFIG.gaTrackingId + '\', \'auto\');';
|
||||||
|
document.body.appendChild(keyScript);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// support async tag or hmr
|
// support async tag or hmr
|
||||||
if (hasValue(ENV_CONFIG.universal) && ENV_CONFIG.universal.preboot === false) {
|
if (hasValue(ENV_CONFIG.universal) && ENV_CONFIG.universal.preboot === false) {
|
||||||
bootloader(main);
|
bootloader(main);
|
||||||
|
Reference in New Issue
Block a user