Matomo Analytics for WordPress

matomo-for-wordpress

 

Matomo, formerly Piwik is a free and open source web analytics application. It tracks online visits to one or more websites and displays reports on these visits for analysis. To read more on open source software please click here.

It is a good alternative for Google Analytics.

In this article we will see how to integrate Matomo analytics tool with open source CMS WordPress, Joomla and Drupal. To read more on installing Matomo on-premise please click here

Matomo WordPress Integration

If you don’t have Matomo On-Premise or a Matomo Cloud account then you can install Matomo WordPress Plugin to your existing WordPress site. You can choose any of the option below to install plugin. You can also get more information on my old post here.

Requirements

  • PHP 7.2 or greater
  • MySQL 5.5 or greater is recommended
  • 128MB memory or greater is recommended
  • WordPress 4.8 or greater
  • If you are unaware of your server’s capacity, we recommended only using for websites up to 50K page views/month
  • If your not sure of your servers capacity you can also host Matomo through our Cloud service or host Matomo On-Premise

Option 1. Install through the WordPress plugins directory

Log in to your WordPress Admin Dashboard.

matomo wp plugin

Go to Plugins and click Add new. Search for “Matomo Analytics Ethical Stats”

matomo plugin

  • Click on Install
  • Click on Activate

Option 2. By downloading the plugin and uploading the files to your server

In rare cases, you may need to install a plugin by manually transferring the files onto the server. Should you not be able to install the plugin this way, please download the zip file of the plugin. https://downloads.wordpress.org/plugin/matomo.latest-stable.zip Now unzip the content and upload it on to your server using ftp, ssh, or similar. Make sure the plugin is placed in the wp-content/plugins/matomo directory

This procedure requires you to be familiar with the process of transferring files using an SFTP client.

Warning: this process may put your site at risk if you install a WordPress plugin incompatible with the current version or from an unreliable source. Back up your site completely before proceeding.

  • If your plugin is in the form of a zip file, unzip the contents. You should see a single folder named after the plugin.
  • Connect to your WordPress server with your SFTP client.
  • Copy the plugin folder to the wp-content/plugins folder in your WordPress directory. This installs the plugin to your WordPress site.

  • Navigate to your Plugins admin screen and locate the newly uploaded plugin in the list. Click on Activate link

Once successfully activated, you will see a Get started link, click on it

matomo-cms-fileupload-local-get-started

Click on “Enable Tracking Now” to enable tracking for your website

Tracking is enabled now. Clear the cache if any.

Option 3. By downloading the plugin and uploading the zip file

Your upload might result in some error. This is often because servers have some default limits configured on how much data can be uploaded by default and how long it can take to upload it max. These limits can be exceeded when uploading the plugin. The easy way to workaround this is to try another way of installing it (see previous options). The more complicated and technical way is to change your PHP configuration where you would need to tweak PHP settings like these

upload_max_filesize = 20M

max_input_time = 600

max_execution_time = 600

How these settings can be changed depends on your hoster / server.

Matomo WordPress Integration Plugin

This plugin uses the Matomo API to show your Matomo statistics in your 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 supports WordPress networks and manages multiple sites and their tracking codes. To use this plugin the Matomo web analytics application is required.  <internal link> use this to install Matomo on-premise.

Download the wp-piwik integration plugin from here https://downloads.wordpress.org/plugin/wp-piwik.1.0.24.zip

= Install WP-Matomo on a simple WordPress blog =

1. Upload the full `wp-piwik` directory into your `wp-content/plugins` directory.

2. Activate the plugin through the ‘Plugins’ menu in WordPress.

 

3. Open the new ‘Settings/WP-Matomo (WP-Piwik) Settings’ menu. 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 enter mysite in this field.

In the “Auth token” text field, type your Matomo authentication token. To get the Auth Token, please continue reading further, I have covered that part as well

  • 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”
  • Click on “Save Changes” and a success message will appear
  • 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

matomo-cms-dashboard

Matomo statistics dashboard

matomo-cms-dashboard-stats

  • 4. If you have view access to multiple site stats and did not enable “auto config”, choose your blog and save settings again.
  • 5. Look at ‘Dashboard/WP-Matomo (WP-Piwik)’ to see your site stats.

= Install WP-Matomo on a WordPress blog network (WPMU/WP multisite) =

There are two differents methods to use WP-Matomo in a multisite environment:

* As a Site Specific Plugin it behaves like a plugin installed on a simple WordPress blog. Each user can enable, configure and use WP-Matomo on his own. Users can even use their own Matomo instances (and accordingly they have to).

* Using WP-Matomo as a Network Plugin equates to a central approach. A single Matomo instance is used and the site admin configures the plugin completely. Users are just allowed to see their own statistics, site admins can see each blog’s stats.

*Site Specific Plugin*

Just add WP-Matomo to your /wp-content/plugins folder and enable the Plugins page for individual site administrators. Each user has to enable and configure WP-Matomo on his own if he wants to use the plugin.

Where can I find the Matomo URL and the Matomo auth token? =

Generate Matomo Auth token

To generate a token_auth follow these steps:

Log in to Matomo

  • Go to the Matomo Admin through the top menu
  • Click on Personal -> Security

In the bottom of the page click on “Create new token”

Confirm your account password

Enter the purpose for this plugin as a description, Click on “Create new token”

Make note of this auth token and keep it at secret place.

Common Issues in Matomo WordPress Integration

Here is the list of common issues you might come accross while integrating Matomo with your WordPress website

  • I have a high traffic website, will it be an issue to use Matomo for WordPress?
  • How do I set user permissions in Matomo for WordPress (WordPress Users Permissions)?
  • Which plugins is Matomo for WordPress known to be not compatible with?
  • How do I enable the Tag Manager in Matomo for WordPress when I use the WordPress Multisite feature?
  • How do I disable the Tag Manager in Matomo for WordPress?
  • How do I find the JavaScript tracker URL that is used in Matomo for WordPress?
  • How do I suppress DB errors in Matomo for WordPress?
  • How do I change the timezone in Matomo for WordPress?
  • How do I migrate all my data from Matomo for WordPress to Matomo On-Premise?
  • How do I install a Matomo Marketplace plugin in Matomo for WordPress
  • How do I delete or reset the Matomo for WordPress data completely?
  • How do I manually delete or reset all Matomo for WordPress data?
  • I have a high traffic website, how do I disable automatic execution of DB upgrades?
  • I have an issue with the plugin, how do I troubleshoot and enable debug mode?
  • How do I prevent the Geo IP database from being downloaded into multiple directories in Matomo for WordPress when using MultiSite mode?
  • I want to extend the WordPress plugin, where is the documentation?
  • I cannot open the Matomo Reporting, Admin, or Tag Manager page, how do I troubleshoot it?
  • How do I find and copy the system report in Matomo for WordPress?
  • Matomo for WordPress is not showing any statistics / reports, how do I fix it?
  • How do I migrate all my data from Matomo for WordPress to the Matomo Cloud?
  • How do I fix the error “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.” in Matomo System Report
  • How do I make Matomo for WordPress work when it is behind a CDN or proxy?
  • How do I find the path to the Matomo config file in1` Matomo for WordPress?

Please refer this page to resolve above issues.

Conclusion

So, in this article we saw how to integrate Matomo Analytics with WordPress. Also how to add tracking code in these CMS tools.

As we have seen there are multiple options to integrate wordpress with Matomo, so based on your requirement you can choose the option.

Such out-of-the-box plugins would save a lot of our time and hopefully this article would save some of your time while integrating Matomo.

As we have seen in this artical, you will need to have a Matomo server up and running before you actually start using Matomo for your website. As opposed to this for Google Analytics you dont have to worry about the server installation as that is taken care by Google itself.

So, if your data is private or PII data you can choose this open source alternative to Google.

If you have any queries/doubts please post those in the comment section below.

References and links

matomo.org

Tags:

Leave a Reply