Where and how to place PIWIK tracking code?

Posted in: Newsmag
Post count: 6

Hi, can anybody tell me where to place the piwik tracking code?

And how to place it? I am really confused as under custom CSS -ADVANCED CSS- javascript- there are some other instruction to leave out <script> and </script> in the code. So how should I aadapt this code?

<!– Piwik –>
<script type=”text/javascript”>
var _paq = _paq || [];
_paq.push([‘trackPageView’]);
_paq.push([‘enableLinkTracking’]);
(function() {
var u=”//MYWEBSITE.COM/piwik/”;
_paq.push([‘setTrackerUrl’, u+’piwik.php’]);
_paq.push([‘setSiteId’, 1]);
var d=document, g=d.createElement(‘script’), s=d.getElementsByTagName(‘script’)[0];
g.type=’text/javascript’; g.async=true; g.defer=true; g.src=u+’piwik.js’; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p></p></noscript>
<!– End Piwik Code –>

Post count: 6535

Hi

You can use theme’s custom javascript field to add your code in the theme. That filed add automatically the <script> tag so you don’t have to use it in your code.

Thanks!

  • This reply was modified 10 years by Andrei L..
Post count: 9544

We put ours at bottom of the single template being used for our posts as default, and then the one other template being used for older content (where photo was already in the post). We only track posts, hence our reasoning there.

Note for tracking /AMP pages, we’re still testing the single pixel image tracker instead.

If you’re setting up PIWIK you should know what I’m talking about 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newsmag’ is closed to new topics and replies.