> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Matomo with WordPress

> Discover how to integrate Matomo with WordPress for visitor stats using a plugin or direct theme editing.

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

## Using Matomo with WordPress

Matomo gathers detailed statistics about visitor traffic to your site. You can integrate Matomo 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.

<Warning>
  **Important**

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

  * If your hosting account includes Softaculous, you can use it to [install Matomo](/docs/matomo).

  * If your hosting account does not include Softaculous, or if you want to install the newest version, you can [install Matomo manually](/docs/installing-matomo-manually).
</Warning>

### Method #1: Use a WordPress plugin

There are several plugins available for WordPress that provide Matomo integration, but Matomo's own site recommends [WP-Matomo](https://wordpress.org/plugins/wp-piwik/). This section describes how to install and configure this plugin.

#### Installing WP-Matomo

To install the WP-Matomo 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-matomo`, and then press Enter.

5. Locate **WP-Matomo Integration (WP-Piwik)**, and then click **Install Now**.

6. After WordPress finishes installing the plugin, click **Activate**.

#### Configuring WP-Matomo

After you install the WP-Matomo plugin, you must configure it to work with your Matomo 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 Matomo** tab, in the **Matomo Mode** list box, select **Self-hosted (HTTP API, default)**.

4. In the **Matomo URL** text box, type the URL where you installed Matomo (for example, *[https://example.com/matomo](https://example.com/matomo)* ).

5. In the **Auth token** text box, type your Matomo authentication token.
   > 👍 Tip
   >
   > To obtain your Matomo authentication token, follow these steps:
   >
   > 1. Log in to Matomo.
   >
   > 2. On the top right of the page, click the Administration (![Matomo - Administration settings icon](https://static.hosting.com/kb/kb-matomo-settings-icon.png)) icon.
   >
   > 3. In the left sidebar, click **Personal**, and then click **Security**.
   >
   > 4. Under **Auth tokens**, click **CREATE NEW TOKEN**.
   >
   > 5. Type your password again to confirm your identity.
   >
   > 6. In the **Description** text box type a description for the token, such as **WordPress**, and then click **CREATE NEW TOKEN**.
   >
   > 7. Under **Token successfully generated**, copy the long alphanumeric string. This is your Matomo authentication token.

6. Confirm the **Auto config** check box is selected.

7. Click **Save Changes**. You should receive a **WP-Matomo is successfully connected to Matomo** 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 Matomo 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 Matomo.

<Warning>
  **Important**

  One disadvantage of editing the theme directly is that if the theme is updated, the Matomo 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 [http://codex.wordpress.org/Child\_Themes](http://codex.wordpress.org/Child_Themes).
</Warning>

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

1. Log in to your Matomo account as the administrator:

* On the top right of the page, click the Administration (![Matomo - Administration settings icon](https://static.hosting.com/kb/kb-matomo-settings-icon.png)) icon.

* In the left sidebar, click **Websites**, and then click **Tracking Code**.

* Under **JavaScript Tracking Code**, copy the entire text in the tracking code box, including the starting **\{/*Matomo*/}** tag and the ending **\{/*End Matomo Code*/}** tag.

2. Log in to WordPress as the administrator.

3. Under **Dashboard**, click **Appearance**, and then click **Theme Editor**. The **Edit Themes** page appears.

4. Under **Theme Files**, click **Theme 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**. Matomo is now enabled for all pages on your WordPress site. To view site statistics, log in to your Matomo account.

## More information

For more information about Matomo, please visit [https://matomo.org](https://matomo.org).

## Related articles

* [Installing Matomo manually](/docs/installing-matomo-manually)

* [Using Google Analytics with WordPress](/docs/using-google-analytics-with-wordpress)
