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.
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. 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:- Log in to your WordPress site as the administrator.
- In the left-hand pane, click Plugins.
- Click Add New.
-
In the Search Plugins text box, type
wp-matomo, and then press Enter. - Locate WP-Matomo Integration (WP-Piwik), and then click Install Now.
- 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:- Log in to your WordPress site as the administrator.
- In the left-hand pane, click Settings, and then click WP-Piwik. The WP-Piwik Settings page appears.
- On the Connect to Matomo tab, in the Matomo Mode list box, select Self-hosted (HTTP API, default).
- In the Matomo URL text box, type the URL where you installed Matomo (for example, https://example.com/matomo ).
-
In the Auth token text box, type your Matomo authentication token.
👍 Tip To obtain your Matomo authentication token, follow these steps:
- Log in to Matomo.
-
On the top right of the page, click the Administration (
) icon.
- In the left sidebar, click Personal, and then click Security.
- Under Auth tokens, click CREATE NEW TOKEN.
- Type your password again to confirm your identity.
- In the Description text box type a description for the token, such as WordPress, and then click CREATE NEW TOKEN.
- Under Token successfully generated, copy the long alphanumeric string. This is your Matomo authentication token.
- Confirm the Auto config check box is selected.
- 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.
- Click the Enable Tracking tab.
- In the Add tracking code list box, select Default tracking.
- Click Save Changes.
- 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. To enable Matomo by editing the theme, follow these steps:- Log in to your Matomo account as the administrator:
-
On the top right of the page, click the Administration (
) 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.
- Log in to WordPress as the administrator.
- Under Dashboard, click Appearance, and then click Theme Editor. The Edit Themes page appears.
- Under Theme Files, click Theme Footer (footer.php).
- Locate the ending </body> tag. Just above the </body> tag, paste the tracking code snippet that you obtained in step 1.
- Click Update File. Matomo is now enabled for all pages on your WordPress site. To view site statistics, log in to your Matomo account.