Tracking Code Implementation Using WordPress Plugin

If you’re running your website on a WordPress platform, you can and add both – asynchronous and synchronous tags – using Piwik PRO Tag Manager Integration Plugin.

Once you install the plugin to your website, all you have to do to start tracking your data is to add your Piwik PRO Instance URL and the ID of the website and select the tracking method. We’ll show you how to do it step by step.

Installing the Plugin

To install the WordPress plugin, follow these steps:

  1. Go to your WordPress Admin Dashboard, from the left-hand menu select Plugins, and click the Add New button.
  2. In the search box, type in Piwik PRO Tag Manager Integration.
  3. Click Install Now and then click Activate.

How to install Piwik PRO Tag Manager Integration Plugin.

Plugin configuration

Once the WordPress plugin is activated, you can add the tracking code from Piwik PRO.

Installing the Asynchronous Code

To add an asynchronous tag to your website, follow these steps:

  1. Navigate to Settings and select Piwik PRO Tag Manager Integration.
  2. Open Include tags in body section tab.
  3. In the Server URL field, input the address of your instance ending with /containers. For example, clearbank.piwik.pro/containers. This will direct WordPress to the Piwik PRO Tag Manager’s container of your instance. This setup will not work for an on-prem or private cloud instance. If you have this type of an instance, please reach out to your dedicated contact person at Piwik PRO to confirm the server URL.
  4. Copy your website ID from Piwik PRO. To find the ID go to Piwik PRO > Menu > Administration > Websites & apps, and pick your website. The ID is under the name of your website.
  5. In the Website ID field, input your website ID.
  6. Enable the output buffering checkbox.

Installing the Synchronous Code

To add a synchronous tag to your website, follow these steps:

  1. Navigate to Settings and select Piwik PRO Tag Manager Integration.
  2. Open Include tags in head section tab.
  3. In the Server URL field, input the address of your instance ending with /containers. For example, clearbank.piwik.pro/containers. This will direct WordPress to the Piwik PRO Tag Manager’s container of your instance. This setup will not work for an on-prem or private cloud instance. If you have this type of an instance, please reach out to your dedicated contact person at Piwik PRO to confirm the server URL.
  4. Copy your website ID from Piwik PRO. To find the ID go to Piwik PRO > Menu > Administration > Websites & apps, and pick your website. The ID is under the name of your website.
  5. In the Website ID field, input your website ID.
  6. Enable the wp_head checkbox.

Multisite

The plugin also works for multisite WordPress networks. You can learn how to track multiple urls within one Piwik PRO instance here. Once the instance is set and ready – please use one of the following approaches according to desired level of implementation:

  • Activate the plugin at the site level to load the plugin only on given website.
  • Activate the plugin at the network level for full integration with all sites in your network.

The basic configuration instruction above works for all types of WordPress themes and implementations. Below you can find information regarding additional plugin settings for more advanced users.

Additional settings and information

Method section

Include tags in body section – for asynchronous tags
In this section you can choose whether you would like to use wp_body function to place the code snippet (for asynchronous tags) or the output buffering mode which adds snippet in section using output buffering. You should choose output buffering only if you are not sure if the wp_body function is added to your theme and/or you don’t have enough skills or access to source code of your theme so that you can’t add wp_body function by yourself.

Pic 1. Method section for asynchronous tags.

Include tags in head section – for synchronous tags
In this section wp_head function is the preferred method to place the code snippet (for asynchronous tags), use output buffering mode which adds snippet in section, only if you are not sure if the wp_head function is added to your theme.

Method section for synchronous tags

Dependencies section

This section enables you to define which dependencies scripts should be loaded before Piwik PRO Tag is loaded. Please note that this feature works only with wp_body or wp_head method enabled.

Dependencies section for asynchronous tags.

Dependencies section for synchronous tags.

Cache section

In this section you can enable a cache mechanism which serves the script from a file stored on the website host server. The feature enables you to:

  • set the cache refresh interval (in minutes);
  • whether or not the script’s url should be rewritten to more friendly (.htaccess modification required);
  • force delete all cached files and directories manually;

There is also a instruction – how to configure cron available in the Cache section. It’s a preferred method to to trigger the wp_cron function.

Cache section (same for both synchronous and asynchronous tags).

Version section

This section allows user to add the query parameter ?ver= to the script’s url.

Version section (same for both synchronous and asynchronous tags).

Snippet section

In this section you need to verify whether your Piwik PRO Tag Manager is version 1.16.0 and higher or not and act accordingly:
version 1.16.0 and higher – leave the box checked (it’s selected by default);
version lower than 1.16.0 – uncheck the box.

Snippet section (same for both synchronous and asynchronous tags).

Was this article helpful?

of people found this helpful

Technical Support

If you have any questions, drop us a line at support_SPC@piwik_SPC.pro.

We’re happy to help!