Piwik js tracking code


(cauzenne) #1

Is this the correct code that i need to insert in order to get piwik working on a local site?
The url is correctly pointing to my installation of piwik. I should also mention im doing this in Modx. If anyone can help, thank you in advance.

Sorry if ive posted in the wrong section.

Regards.

<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://sh.localhost/piwik/index.php" : "http://sh.localhost/piwik/index.php");
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", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script>

(hackaway) #2

I’m doing my sites also in MODx, but that doesn’t really matter. Just copy and paste the code piwik generates into your template before the closing tag, or create a chunk, name it ‘PiwikAnalytics’ or whatever, and insert it as {{PiwikAnalytics}} before the

Not sure if that’s what you’re asking for. If you can open the piwik installation locally and if your site works locally, then justs open a page in your browser and check if piwik is tracking the hits.


(vipsoft) #3

pkbaseurl shouldn’t have any reference to index.php.


(cauzenne) #4

It’s all working correctly now. Thanks guys.