Note: If you are using WooCommerce, see this installation guide.
If you’re running your website on WordPress, you can quickly add our container (with tracking code) using a dedicated plugin and start collecting data about your visitors. First you’ll need to add your site to Piwik PRO. Then you’ll need to install and configure our plugin in WordPress.
In this article, we will guide you through the entire installation process.
Add a site in Piwik PRO
To add your WordPress site in Piwik PRO, follow these steps:
- Go to Menu > Administration.
- Navigate to Sites & apps.
- Click Add a site or app.
- Type the site or app name and address and click Save.
Note: If you want to track a few domains with the same tracking code, add their addresses.
- Set the time zone and currency.
Note: We’ll show data in reports in this time zone. We’ll use this currency for goal revenue.
Install a container with the WordPress plugin
Note: You need to have an administrator role in WordPress to add and manage plugins.
To install a container (with a tracking code) using our WordPress plugin, follow these steps:
- In your WordPress admin panel, go to Plugins > New Plugin.
- Search for Piwik PRO or install the plugin form wordpress.org.
- Click Install now.
- Click Activate.
- Go to Settings > Piwik PRO.
- Type in the container address (URL).
Note: Enter your Piwik PRO account address with containers added to the address.
- For standard domains:
https://yourname.containers.piwik.pro
- For custom domains:
https://yourname.piwik.pro/containers
This address may be different for Piwik PRO on-premises or private cloud accounts. Contact us to get the right address.
- For standard domains:
- Type in your site ID. Where to find it?
- Leave Basic container (async) checked. This container holds your tracking code and is used to handle all tags.
Note: Make sure your WordPress theme has the
wp_body_open()
function right after the opening<body>
tag, otherwise the container won’t work. - (Optional) Rename the data layer.
Note: Rename the data layer if you use other software with data layers. If the names are the same, the software can interfere with each other.
To check if your data layer name is not used by other software on your site, follow these steps:- In the console on your site, run this command:
!window.hasOwnProperty("customDataLayer")
; replacingcustomDataLayer
with your custom name. - If this command returns true, then you can safely use your custom name.
- In the console on your site, run this command:
- Click Save changes.
- Done! Data will appear in reports in about an hour. Data in the tracker debugger will appear instantly.
Tip: You can also check manually to see if your tracking works. Read more
- We’ll start showing a consent form on your site after you’ve installed the container. Add your privacy policy address to the form or turn off the consent form.
Tip: To change the way your data is collected, you can use the following settings:
Support the Content Security Policy mechanism
The Content Security Policy restricts third-party tools from loading code onto your site and only allows content from approved origins to be fetched. To support the Content Security Policy mechanism when using our WordPress plugin, you need to add a nonce
value as an attribute to the containers and scripts that these containers load.
To add a nonce
value, follow these steps:
- Add the following code to the
function.php
file in your theme:add_filter( 'piwik_pro_nonce', function() { return wp_create_nonce( time() ); } );
Tip: For more, see this article: Content Security Policy.