Beispiel #1
0
function insert_analytics_tracking() {
    global $CFG;
    $enabled = get_config('local_analytics', 'enabled');
    $siteid = get_config('local_analytics', 'siteid');
    $trackadmin = get_config('local_analytics', 'trackadmin');
    $cleanurl = get_config('local_analytics', 'cleanurl');
    $location = "additionalhtml" . get_config('local_analytics', 'location');

    if ($enabled && (!is_siteadmin() || $trackadmin)) {
        $CFG->$location .= "
            <script type='text/javascript' name='localga'>
              var _gaq = _gaq || [];
              _gaq.push(['_setAccount', '" . $siteid . "']);
              _gaq.push(['_trackPageview'," . ($cleanurl ? analytics_trackurl() : '') . "]);
              _gaq.push(['_setSiteSpeedSampleRate', 50]);

              (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; 
                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>
			";
    }
}
Beispiel #2
0
function insert_analytics_tracking() {
    global $CFG, $PAGE;
    $enabled = get_config('local_analytics', 'enabled');
    $siteid = get_config('local_analytics', 'siteid');
    $trackadmin = get_config('local_analytics', 'trackadmin');
    $cleanurl = get_config('local_analytics', 'cleanurl');
    $location = "additionalhtml" . get_config('local_analytics', 'location');

    if ($cleanurl) {
        $addition = "{'hitType' : 'pageview',
            'page' : " . analytics_trackurl() . ",
            'title' : '" . addslashes($PAGE->heading) . "'
            }";
    } else {
        $addition = "'pageview'";
    }


    if ($enabled && (!is_siteadmin() || $trackadmin)) {
        $CFG->$location .= "   
            <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','//www.google-analytics.com/analytics.js','ga');
            ga('create', '" . $siteid . "', {'siteSpeedSampleRate': 50});
            ga('send', " . $addition . ");
			
            </script>
			";
    }
}
function insert_analytics_tracking()
{
    global $PAGE, $OUTPUT;
    $trackadmin = false;
    $cleanurl = false;
    if (isset($PAGE->theme->settings->analyticstrackingid)) {
        $trackingid = $PAGE->theme->settings->analyticstrackingid;
    }
    if (isset($PAGE->theme->settings->analyticstrackadmin)) {
        $trackadmin = $PAGE->theme->settings->analyticstrackadmin;
    }
    if (isset($PAGE->theme->settings->analyticscleanurl)) {
        $cleanurl = $PAGE->theme->settings->analyticscleanurl;
    }
    $tracking = '';
    if ($cleanurl) {
        $addition = "{'hitType' : 'pageview',\n            'page' : " . analytics_trackurl() . ",\n            'title' : '" . addslashes($PAGE->heading) . "'\n            }";
    } else {
        $addition = "'pageview'";
    }
    if (!is_siteadmin() || $trackadmin) {
        $tracking = "\n            <script>\n            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n            })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n            ga('create', '" . $trackingid . "', {'siteSpeedSampleRate': 50});\n            ga('send', " . $addition . ");\n\n            </script>";
    }
    return $tracking;
}
Beispiel #4
0
function insert_analytics_tracking() {
    global $CFG;
    $enabled = get_config('local_analytics', 'enabled');
    $imagetrack = get_config('local_analytics', 'imagetrack');
    $siteurl = get_config('local_analytics', 'siteurl');
    $siteid = get_config('local_analytics', 'siteid');
    $trackadmin = get_config('local_analytics', 'trackadmin');
    $cleanurl = get_config('local_analytics', 'cleanurl');
	$location = "additionalhtml".get_config('local_analytics', 'location');
    
	if (!empty($siteurl)) {
		if ($imagetrack) {
			$addition = '<noscript><p><img src="//'.$siteurl.'/piwik.php?idsite='.$siteid.' style="border:0" alt="" /></p></noscript>';
		} else {
			$addition = '';
		}
		
		if ($cleanurl) {
			$doctitle = "_paq.push(['setDocumentTitle', ".analytics_trackurl()."]);";
		} else {
			$doctitle = "";
		}
		
		if ($enabled && (!is_siteadmin() || $trackadmin)) {
			$CFG->$location .= "
				<script type='text/javascript'>
					var _paq = _paq || [];
					(function(){ var u=(('https:' == document.location.protocol) ? 'https://".$siteurl."/' : 'http://".$siteurl."/');
					_paq.push(['setSiteId', ".$siteid."]);
					_paq.push(['setTrackerUrl', u+'piwik.php']);
					_paq.push(['trackPageView']);
					".$doctitle."
					_paq.push(['enableLinkTracking']);
					var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js';
					s.parentNode.insertBefore(g,s); })();
				</script>
				".$addition;
		}
	}
}