diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-07-16 10:56:46 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-07-16 10:56:46 -0400 |
commit | c055449ee086b617891f6efa31cfab487336ec44 (patch) | |
tree | 893f40d9396b7500b49397260ac1d689055e2dc0 /plugins/PiwikAnalyticsPlugin.php | |
parent | 3c2006eb13ece3cc22a4d0a80716c9e74a677f14 (diff) |
update Piwik analytics code
Diffstat (limited to 'plugins/PiwikAnalyticsPlugin.php')
-rw-r--r-- | plugins/PiwikAnalyticsPlugin.php | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/plugins/PiwikAnalyticsPlugin.php b/plugins/PiwikAnalyticsPlugin.php index d2c52354e..dc3c7c37f 100644 --- a/plugins/PiwikAnalyticsPlugin.php +++ b/plugins/PiwikAnalyticsPlugin.php @@ -87,18 +87,25 @@ class PiwikAnalyticsPlugin extends Plugin function onEndShowScripts($action) { - $js1 = 'var pkBaseURL = (("https:" == document.location.protocol) ? "https://'. - $this->piwikroot.'" : "http://'.$this->piwikroot. - '"); document.write(unescape("%3Cscript src=\'" + pkBaseURL + "piwik.js\''. - ' type=\'text/javascript\'%3E%3C/script%3E"));'; - $js2 = 'piwik_action_name = ""; piwik_idsite = '.$this->piwikid. - '; piwik_url = pkBaseURL + "piwik.php"; piwik_log(piwik_action_name, piwik_idsite, piwik_url);'; - $action->elementStart('script', array('type' => 'text/javascript')); - $action->raw($js1); - $action->elementEnd('script'); - $action->elementStart('script', array('type' => 'text/javascript')); - $action->raw($js2); - $action->elementEnd('script'); + $piwikCode = <<<ENDOFPIWIK + +<!-- Piwik --> +<script type="text/javascript"> +var pkBaseURL = (("https:" == document.location.protocol) ? "https://{$this->piwikroot}" : "http://{$this->piwikroot}"); +document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); +</script> +<script type="text/javascript"> +try { + var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 4); + piwikTracker.trackPageView(); + piwikTracker.enableLinkTracking(); +} catch( err ) {} +</script> +<!-- End Piwik Tag --> + +ENDOFPIWIK; + + $action->raw($piwikCode); return true; } }
\ No newline at end of file |