Track the most popular categories (wordpress)

Hello guys,

thanks for the great product like Piwik is :slight_smile:

I want to track the most popular categories, so I know which categories are the most popular ones

I have stumbled upon across this tutorial Custom Variable Case Study: Divezone.net - Analytics Platform - Matomo

but it doesn’t work

I have added the variable code, so my current tracking code is


<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  
  <?php
$category = get_the_category();
if (!empty($category[0])) {
    echo 'piwikTracker.setCustomVariable(1, "Type", "'.$category[0]->cat_name.'", "page");';
}
if (!empty($category[1])) {
    echo 'piwikTracker.setCustomVariable(2, "Location", "'.$category[1]->cat_name.'", "page");';
}
?>
  
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://bluishjobs.com/piwik/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', 2]);
    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>
<noscript><p><img src="http://bluishjobs.com/piwik/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->

but nothing happens when i go to visitors > custom variables in my dashboard. It says ’ There is no data for this report. ’

I really hope someone can help me with this, I need this.

Thanks :slight_smile:

this tutorial uses the old Piwik tracker code. Now the code looks like _paq.push([‘function’ rather than piwikTracker.function

Thanks

I found solution here

https://wordpress.org/support/topic/feature-request-adding-custom-variables