Ho!
ich hab das Google Analytics-Template angepasst. Google empfiehlt den Code in den <head>-Tag zu speichern, daher habe ich das Script einfach in $GLOBALS['TL_HEAD'][] gelegt.
PHP-Code:
<?php
/**
* To use this script, please fill in your Google Analytics ID below
*/
$GoogleAnalyticsId = 'UA-XXXXX-X';
/**
* DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!
*/
if ($GoogleAnalyticsId != 'UA-XXXXX-X' && !BE_USER_LOGGED_IN && sha1(session_id() . (!$GLOBALS['TL_CONFIG']['disableIpCheck'] ? Environment::get('ip') : '') . 'BE_USER_AUTH') != Input::cookie('BE_USER_AUTH')){
$Script = "<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '".$GoogleAnalyticsId."']);";
if ($GLOBALS['TL_CONFIG']['privacyAnonymizeGA']){
$Script .= "_gaq.push(['_gat._anonymizeIp']);";
}
$Script .= "_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>";
$GLOBALS['TL_HEAD'][] = $Script;
}
Der Code wird dann einfach im Head ausgegeben. Hier könnt ihr es im Quelltext sehen: http://www.kommunikation-design.de
Der Nachteil ist eigentlich, dass der Code nicht direkt vor </head> steht, aber immerhin wäre es so mal im Header, evt könnte man hier noch die Umbrüche und Leerzeichen per PHP entfernen. Der zweite Nachteil ist, dass das Syntaxhighlighting nicht mehr funktionieren kann, aber das braucht man in dem Fall eh nicht wirklich.
Lesezeichen