Knowledge Base

How to use Piwik with WordPress

This article describes how to integrate WordPress with the open-source Piwik analytics platform.

Using Piwik with WordPress

Piwik gathers detailed statistics about visitor traffic to your site. You can integrate Piwik with WordPress using either of the following methods:

  • Installing and configuring a WordPress plugin.
  • Editing the WordPress theme directly.

The following sections describe how to do both of these methods.

Before you can use Piwik with WordPress, you must first install the Piwik application files. There are two ways to do this:

  • If your hosting account includes Softaculous, you can use it to install Piwik.
  • If your hosting account does not include Softaculous, or if you want to install the newest version, you can install Piwik manually.
Method #1: Use a WordPress plugin

There are several plugins available for WordPress that provide Piwik integration, but Piwik's own site recommends WP-Piwik. This section describes how to install and configure this plugin.

Installing WP-Piwik

To install the WP-Piwik plugin on your WordPress site, follow these steps:

  1. Log in to your WordPress site as the administrator.
  2. In the left-hand pane, click Plugins.
  3. Click Add New.
  4. In the Search Plugins text box, type wp-piwik, and then press Enter.
  5. Locate WP-Piwik, and then click Install Now.
  6. After WordPress finishes installing the plugin, click Activate Plugin.
Configuring WP-Piwik

After you install the WP-Piwik plugin, you must configure it to work with your Piwik installation. To do this, follow these steps:

  1. Log in to your WordPress site as the administrator.
  2. In the left-hand pane, click Settings, and then click WP-Piwik. The WP-Piwik Settings page appears.
  3. On the Connect to Piwik tab, in the Piwik Mode list box, select Self-hosted (PHP API).
  4. In the Piwik path text box, type the directory where you installed Piwik (for example, /home/username/public_html/piwik, where username represents your account username).
  5. In the Auth token text box, type your Piwik authentication token.
    To obtain your Piwik authentication token, follow these steps:
    1. Log in to Piwik.
    2. On the top right of the page, click your administrator username.
    3. On the left menu bar, under Platform, click API.
    4. Under User authentication, copy the long alphanumeric string. This is your Piwik authentication token. (Do not copy the &token_auth= portion.)
  6. Confirm the Auto config check box is selected.
  7. Click Save Changes. You should receive a WP-Piwik is successfully connected to Piwik message. If you do not, check the values you provided in steps 3 to 6, and then try again.
  8. Click the Enable Tracking tab.
  9. In the Add tracking code list box, select Default tracking.
  10. Click Save Changes.
  11. To view Piwik statistics for your site, in the left-hand pane, click Dashboard, and then click WP-Piwik. The Piwik Statistics page appears with visitor statistics, site search statistics, and more.
Method #2: Edit the theme

Plugins are convenient, but they also carry processing overhead with them that can affect site performance. If you prefer not to use a plugin, you can edit the WordPress theme directly to enable Piwik.

One disadvantage of editing the theme directly is that if the theme is updated, the Piwik modifications are overwritten. To avoid this scenario, you should use a child theme instead of editing the base parent theme. For detailed information about how to set up a child theme in WordPress, please visit

To enable Piwik by editing the theme, follow these steps:

  1. Log in to your Piwik account as the administrator:
    • On the top right of the page, click your administrator username.
    • Under Manage, click Tracking Code.
    • Under JavaScript Tracking Code, copy the entire text in the tracking code box, including the starting <!—Piwik—> tag and the ending <!—End Piwik Code—> tag.
  2. Log in to WordPress as the administrator.
  3. Under Dashboard, click Appearance, and then click Editor. The Edit Themes page appears.
  4. Under Templates, click Footer (footer.php).
  5. Locate the ending </body> tag. Just above the </body> tag, paste the tracking code snippet that you obtained in step 1.
  6. Click Update File. Piwik is now enabled for all pages on your WordPress site. To view site statistics, log in to your Piwik account.

More Information

For more information about Piwik, please visit