2
0
forked from Wavyzz/dolibarr

Fix analytics tag

This commit is contained in:
Laurent Destailleur
2020-06-11 16:38:58 +02:00
parent 5b882e333d
commit 503206af88

View File

@@ -7721,17 +7721,22 @@ function printCommonFooter($zone = 'private')
// TODO Add a hook here // TODO Add a hook here
if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID))
{ {
print "\n"; $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID);
print "/* JS CODE TO ENABLE for google analtics tag */\n"; foreach($tmptagarray as $tmptag) {
print ' var _gaq = _gaq || [];'."\n"; print "\n";
print ' _gaq.push([\'_setAccount\', \''.$conf->global->MAIN_GOOGLE_AN_ID.'\']);'."\n"; print "/* JS CODE TO ENABLE for google analtics tag */\n";
print ' _gaq.push([\'_trackPageview\']);'."\n"; print "
print ''."\n"; <!-- Global site tag (gtag.js) - Google Analytics -->
print ' (function() {'."\n"; <script async src=\"https://www.googletagmanager.com/gtag/js?id=".trim($tmptag)."\"></script>
print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;'."\n"; <script>
print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';'."\n"; window.dataLayer = window.dataLayer || [];
print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);'."\n"; function gtag(){dataLayer.push(arguments);}
print ' })();'."\n"; gtag('js', new Date());
gtag('config', '".trim($tmptag)."');
</script>";
print "\n";
}
} }
// End of tuning // End of tuning