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