How do I install the Matomo tracking code on WordPress?
Matomo for WordPress – When you are not using Matomo yet
Already using Matomo On-Premise or Matomo Cloud? This plugin won’t work. Use the WP-Matomo Integration mentioned in the next section.
Please not that the free site trial provided at WordPress.com cannot be setup to use the Matomo tracking code, due to the inability to install plugins. Moving to a paid WordPress subscription will allow the installation of plugins.
There’s a Matomo Analytics WordPress plugin called Matomo Analytics – Ethical Stats. Powerful Insights. This plugin let’s you very easily and quickly install Matomo Analytics fully in your WordPress. This plugin is recommended for websites of up to 50K page views/month when you don’t already use Matomo On-Premise or Matomo Cloud.
But if you are already using Matomo on our Cloud or On-Premise, then you have to use the WP-Matomo Integration (WP-Piwik) plugin to set up the tracking code see the instructions below in the next section.
For Matomo for WordPress, follow these instructions:
- Install Matomo for WordPress
- To set up the tracking code in Matomo for WordPress simply go to the « WordPress Admin -> Matomo Analytics -> Getting started » page and click on « Enable tracking now ». Alternatively, set the tracking code to « Default tracking » in the « WordPress Admin -> Matomo Analytics -> Settings » page and click on « Save changes ». That’s it. The plugin will put the tracking code automatically into your site. You can optionally configure the tracking code to your liking on the Settings page if you wish.
WP-Matomo Integration (WP-Piwik) – When you use Matomo On-Premise or Matomo Cloud
WP-Matomo Integration (WP-Piwik) plugin uses the Matomo API to show your Matomo statistics in your WordPress.com or self-hosted WordPress dashboard. It’s also able to add the Matomo tracking code to your blog and to do some modifications to the tracking code. Additionally, WP-Matomo Integration (WP-Piwik) supports WordPress networks and manages multiple sites and their tracking codes. This plugin needs to be configured for it to work with Matomo.
You’ll need Matomo (Cloud or On-Premise (self-hosted)) and WordPress (WordPress.com or Self-hosted using WordPress.org).
Integrate Matomo Analytics to your WordPress website
To configure the plugin, follow these steps:
-
Log in to your WordPress site as the administrator
-
Click on « Plugins » from the left menu
-
Search for « WP-Matomo » and click on « Activate »
-
In the left menu, click « Settings » > « WP-Piwik ». The WP-Matomo Settings page appears
-
Click on « Connect to Matomo » tab, and in the « Matomo Mode » dropdown, choose the option « Self hosted (HTTP API, default) ». In the « Matomo URL » text field, enter your Matomo URL for example
analytics.example.com
. -
If your Matomo is cloud hosted select Cloud-hosted (*.matomo.cloud or *.innocraft.cloud) from the Matomo mode drop down, then enter your subdomain in the Matomo subdomain field. For example if your cloud domain is
mysite.matomo.cloud
, just entermysite
in this field. -
In the « Auth token » text field, type your Matomo authentication token. How to find Auth Token
-
Confirm the « Auto config » checkbox is selected and click on “Save Changes”
-
You should see « WP-Matomo is successfully connected to Matomo » message. If you do not see the message, make sure the values you provided in steps 5 to 7 are correct, and then try again
-
Click on « Enable Tracking » tab
-
In the « Add tracking code » dropdown, select « Default tracking »
-
Open your website in the browser and perform some actions (eg: navigate to different pages)
-
To view Matomo statistics for your site, in the left menu, click on Dashboard, then click WP-Piwik. The Matomo Statistics page appears with visitor statistics, site search statistics, and more. To view all the detailed reports please login to your Matomo instance
Congratulations, you should now be successfully tracking visitors with Matomo Analytics through your WordPress site! Happy Analytics.