Best method integrate piwik in WordPress?

What is the recommended method to integrate the PiwikPro code into a WordPress website?

  • Manually add the code to my header file?
  • Using the PiwikPro WordPress plugin?

Regarding the plugin; it has very few users (less than 1000?!) and has not been updated for 4 months. Is this plugin still actively maintained and recommended?

Thanks a lot :slightly_smiling_face:
Alwin

Hello @optipiwik,

The best way to integrate our product with WordPress is to use our official plugin. It’s actively maintained, but very stable, so there was no reason to release updates for a while. It replaced a previous version, so the usage stats are not completely accurate.

Hello Piotrek,

Thank you for your fast reply. I will just use the plugin then :slight_smile:

Hello Piotrek,

When I use the WordPress plugin the code is installed after the closing /head tag.
It is before the closing /header tag but not in the /head like GA code is.

  • Would it not be better to install the PiwikPro code manually and place it before the closing /head tag?

  • I see extra code when I use the WordPress plugin:

<noscript><iframe src="https://option-webdesign.containers.piwik.pro/0ac0d197-f254-48d9-9ffa-67ba0e222f8d/noscript.html" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><div id='wrap_all'>

This extra code is for what?

Thank you,
Alwin

Anyone can help me with this? Need to setup 10 sites for my clients :slight_smile:

Thanks a lot,
Alwin

Sorry for the late reply @optipiwik,

Piwik PRO code has slightly different rules than GA’s snippet - it’s best to leave it as it is.
Basically, the WordPress plugin loads the Piwik PRO Tag Manager and not just Analytics. Because of that, it has an asynchronous tagging container which should be loaded from <body> and a synchronous one that loads from <head>. This way you can use both synchronous and asynchronous tags in our Tag Manager.

The <noscript> tag is useful when JavaScript is not enabled on the website. It also enables you to use <noscript> in Custom tags in Piwik PRO Tag Manager, so that you can also use other marketing pixels (not just our Analytics) when JavaScript is not enabled.

Let me know if this is a good explanation :slightly_smiling_face:

Hello Piotrek,

Thanks for your help :slight_smile:

In the meantime I have uninstalled the PiwikPro plugin from my WordPress sites… just because I don’t like to install plugins (already too many on my sites) if it is not necessary.

So I did install the code manully and placed it in the header.php file from my sites, just before the closing /head tag.

Maybe you can check on one of my sites to see if the code is installed correctly like this:

Thanks a lot!

It looks fine and should work. Keep in mind, that our recommendation is to place it right after the <body> tag. Nevertheless, head also works.

I’ve been experimenting with different methods to add the priwikpro code to a wordpress website:

1 - Via the piwikpro wordpress plugin
2 - Manually insert the piwikpro code into the header
3 - Manually insert shortened piwikpro code (without tag manager) into the header
(No Piwik PRO Tag Manager: install a tracking code | Piwik PRO help center)

I then compared the number of page views counted between piwikpro and google analytics version 4. I wanted to compare this because with the piwikpro wordpress plugin installed, piwkpro registers about 15% less page views than google analytics (both pwikpro and google analytics without ip filters). I tested each of the 3 methods above for 2 weeks, so complete test toke 6 weeks. I find the result remarkable, which is why I share it here:

1 - With the piwikpro wordpress plugin, piwikpro registers about 10 to 15% fewer page views every day than google analytics.

2 - Manually installed with the same piwikpro code (including tag manager) and placed before the closing head tag (the wordpress plugin places the code lower, below the closing head tag and just above the closing header tag) piwikpro registers about 5% less page views than google analytics. So more pageviews then using the plugin.

3 - With the shortened pwikpro code (without tag manager) and placed above the closing head tag, pwikpro registers about 5% more page views than google analytics every day…

Conclusions:

  • With the wordpress plugin pwikpro is missing quit a lot of page views
  • With the code higher in the page, more page views are registered, still les then in google analytics
  • With the short code, without the tag manager part, the number of registered page views is considerably higher! The difference between this method and using the plugin is around 15 to 20%…

I just wonder, is this expected behavior? Is placing the code lower on the page increasing the risk of missing page views? And is using the tag manager also increasing the risk of missing page views? Because in my test it does…

Thanks,
Alwin

That’s really interesting. I’d suspect that some javascript errors are blocking some of the requests. Would it be an option to install an additional tool to capture all js errors while doing tests (there are many such tools, e.g. fullstory)? You could also check within the UI if tere are any js errors tracked (that’s the default setting and errors should be reported as custom events).