There has never been a better time to learn how to install Matomo on your WordPress site. Recently, Austrian and French courts declared that the use of Google Analytics violates EU law because the service sends personal data, such as IP addresses, back to the US.
As a consequence, it is now illegal to use Google Analytics on websites based in those countries. Similar decisions are expected in other EU member states. Therefore, if your website is subject to the EU privacy laws (GDPR), this is definitely something you should look into. Otherwise, you risk hefty fines in the long run.
However, what about your web analytics? How are you supposed to make informed decisions about your site without having any insights into the behavior of your visitors?
Luckily, there are more privacy-friendly alternatives to Google Analytics. One of the most popular is Matomo (formerly known as Piwik) and in this tutorial, I want to go over why and how to install Matomo on your WordPress website. I will cover the features Matomo offers, contrast it with Google Analytics, and show different ways to use it in WordPress. The post will also cover how to import your existing Google Analytics data (so you don’t lose your site history), set up Matomo in a privacy-friendly way, and how to use it (including backups and updates).
It’s a lot to talk about, so feel free to use the links below to jump to the parts that are most relevant to you:
- What is Matomo Analytics?
- Matomo Installation for WordPress: A Step-by-Step Guide
- Importing Existing Google Analytics Data
- Matomo Configuration – Correctly Set Up Your Analytics
- How to Use Matomo Without Cookies
- What Data Does It Track? Understanding Your Website Traffic
- Backing Up Matomo – How to Protect Your Analytics Data
- How to Upgrade to the Latest Version
Alright, let’s go over it all step by step.
What is Matomo Analytics?
Before you install Matomo on your WordPress site, it’s probably worth knowing what it is. Matomo is an open source web analytics suite. Its name means “decent” in Japanese because it has a strong focus on user privacy and transparency.
The software exists in two versions: a cloud version and a self-hosted version called Matomo On-Premise. In this tutorial, I will be using the self-hosted variety, since the cloud version is a commercial product (it’s all a bit like WordPress.org vs WordPress.com).
What Features Does It Provide?
Here is what Matomo offers its users:
- Extensive traffic statistics — With Matomo, you get a lot of the same information that you might be familiar with from Google Analytics. This includes your number of visitors, where they are from, and the devices and browsers they use. You can also learn how they found your site, how they use it, and how well you retain them. In addition, you have the ability to set conversion goals and track them and there are e-commerce features that allow you to understand your users’ shopping behavior. In addition, you can buy extra features like heatmaps , form analytics, A/B testing, and more.
- A strong focus on user privacy — This is one of the main priorities for Matomo and ways it differentiates itself from Google Analytics. You can configure Matomo so that it follows even the strictest data protection policies, including GDPR, HIPAA, and CCPA. Case in point: several governments and government agencies around the globe use it for that very reason.
- Customizability and extendability — It is possible to adjust Matomo Analytics completely to your needs. Track only the data that is relevant to you and that fits the legal environment you work in. Create custom reports to see only the information that you need. You can also extend Matomo with plugins and themes and even write your own. Make your analytics look like your brand if you want to. Plus, you get raw data access for creating custom records and Matomo also has an API that lets you import it into other tools.
- No limitations — Track on as many websites as you want as well as unlimited data, users, and segments.
Matomo vs Google Analytics
One thing that you might ask yourself is why you would prefer Matomo over Google Analytics. Besides the potential legal issues already talked about, it actually offers a few other benefits:
- No data sampling — From a certain point on, Google Analytics samples data instead processing all of it. As a consequence, what you get is more of an educated guess than exact information. This could affect your business decisions in a negative way. Matomo, on the other hand, always works with complete data. It should be noted, however, that the threshold for Google Analytics to use sampling is 500,000 sessions for the free version and 100 million for the paid. So this only affects you if your site is above those numbers (if you are, kudos!).
- GDPR compliance — We have already established that Google Analytics was recently found to be in violation of the European legal framework. Matomo offers a multitude of functionality to make sure that you stay within those limits. I’ll go over how it does that more detailed in the next section. The most important difference to Google Analytics is that the information is stored locally on your own server where you have full control over it and that it’s not sent anywhere else.
- Ability to import Google Analytics data — You can import your historical data over to Matomo. That way, you don’t lose it and can still compare your new analytics with what happened on your site in the past.
Matomo and the GDPR
The biggest draw for people to switch from Google Analytics to Matomo is that it is GDPR compliant pretty much out of the box. Matomo allows you to track website user data in accordance with privacy laws.
For example, in Matomo, the only person who looks at the user data is you. Unlike in Google Analytics, it is not used by the provider to inform their own decisions, only yours. This also allows you to be the only person who makes decisions about what happens to this data and can guarantee that it is not sold on to the highest bidder.
In addition, Matomo has the following settings:
- The ability to give users the option to opt out of being tracked. Matomo also respects
- You can configure how long you keep your tracking data and set expiration dates for cookies.
- Options to anonymize IP addresses and other personal data or simply tell the program not to process it in the first place.
- Matomo does not users across multiple websites unless specifically configured so.
Plus, you know those cookie consent banners that you need to click on every website lately?
Matomo allows you to do away with those by setting the program up to work without cookies. It’s one less annoyance and also eliminates the complication that lots of people will not consent, which can make your data inaccurate. I will talk about this in more detail below.
How Much Does It Cost?
Let’s talk about pricing. First of all, Matomo is an open source project available under the GNU License v3. That means it’s free of charge, free to use, and created by a community of volunteers.
However, that is only for the base, self-hosted version. If you use the cloud version, pricing starts at 19€/month for 50,000 visits with 1.90€ for every additional 5,000 hits. Costs increase along a sliding scale depending on the popularity of your site.
Plus, the cloud version has a number of features the the free version does not and that cost extra if you want them. This includes an Activity log (from 29€/year), WooCommerce Analytics (39€/year), Heatmaps and A/B testing (199€/year each), plus a few more. In addition, servers for the cloud version are located in Germany, eliminating another GDPR headache.
Basically, in the free version you get all standard reports, API access, and unlimited team members, segments, goals, and websites to use Matomo on. For everything else, you will need to pay. However, the standard features are basically what you get with Google Analytics as well, only in a more privacy-friendly manner.
Sounds good? Then let’s talk about how to install Matomo to work with your WordPress website.
Matomo Installation for WordPress: A Step-by-Step Guide
What follows is a Matomo installation tutorial. You will see that the installation itself is super simple but configuring it correctly needs some extra steps.
Manual Installation vs Plugin Solution
What’s important to know is that, generally, you have two ways of using Matomo with WordPress:
- Install it as a standalone solution with a separate database (or even on another server) and connect it to your site via a tracking a code similar to Google Analytics. Plugin options to add the tracking code are also available.
- Use a WordPress plugin to automatically install Matomo on your site and save the tracking data in the same database that your WordPress installation uses.
Both of these methods have their pros and cons. As you will see below, the plugin solution is much quicker and easier. You basically just have to install and activate a plugin, switch on tracking, do some configuration, and you are off to the races. Plus, backup is easier as you will save all your analytics data automatically whenever you back up your WordPress site.
Installing Matomo as a standalone version and connecting it manually is a bit more complex. On the other hand, it offers benefits in terms of security and performance. By keeping your analytics and website separate, even when one is compromised, the other is still safe. Plus, the more you load into one database, the worse it will perform. Therefore, especially for high-traffic websites, the makers of Matomo recommend to host it separately from your WordPress site. Smaller websites can get away with combining the two.
No matter what you decide on, here are both ways to install Matomo in WordPress.
1. Using a Plugin
Let’s start with the plugin solution since this takes a lot less time to explain.
1.1 Install the Matomo WordPress Plugin
If you want to add Matomo to your WordPress website, you can simply do so by installing the official Matomo Analytics plugin. For that, the easiest way is to log into your WordPress site, go to Plugins > Add New and then search for “Matomo”. The plugin should appear in first place.
Click on Install Now and then Activate once it has been downloaded to your site.
1.2 Enable Tracking
After the installation, you automatically land on this page:
Here, all you need to do is click on Enable tracking now so that Matomo analytics start working. Note that, if you are using any form of caching, be it a plugin or from your host, Matomo asks you to clear the cache in order for tracking to be able to commence.
However, that’s it. After that, Matomo has been installed on your WordPress site. I told you it would be easy.
2. How to Install Matomo and Connect it to WordPress Manually
If you decide to install Matomo without a WordPress plugin, here’s how to do it.
2.1 Download Matomo and Upload It to Your Server
The first thing you need to do is download Matomo. For that, go to the download page and click the big green button on the left.
This should result in a zip archive of the software files on your hard drive. Unzip it, the n fire up an FTP client and connect to the server where you want to put the files. You can create a new directory and start the uploading files into it or simply use the matomo folder they are already in. Alternatively, you might also upload the zip file itself and then unpack it on your server. A lot of hosting providers offer tools for that.
The next thing is how to make the files (and – later – your analytics) available for access. If you install Matomo on the same server as your WordPress installation, you have two options:
- Access it via a subdirectory. For example, if you place it in a folder called matomo inside your WordPress directory, it would simply be accessible via yourdomain.com/matomo.
- Give its own directory and create subdomain for it, e.g. tracking.yourdomain.com. If you have your site’s domain registered with the same provider as your webspace, this should be pretty easy to set up. Simply create a subdomain and point it to the folder on your server.
There is also the possibility to put Matomo on a completely different server in order to keep everything separate. In that case, you might have to play around with your A records in order to access a subdomain on an external server. How this works will depend on your setup and where you have your domain and webspace(s). Let me know if you want to do this and find yourself struggling, I am happy to give you some pointers.
In the end, you need the Matomo files on a server somewhere and a domain you can use to access them.
2.2 Create a MySQL Database
The next thing you need to do is make sure you have a MySQL database available for the installation. That’s where Matomo will save the data it collects.
In order to use it, you will need the name of an empty database plus a username that has access to it. In addition, you require the password for that username and the database’s server address (which can also be something like localhost).
You get all of this information from your hosting provider. Look for the menu where you create and manage your MySQL databases.
Once you have all of the above, it’s time to install Matomo.
2.3 Run the Installation
With all the relevant information collected and all files uploaded, you can run the installation. For that, you have to access the URL under which your have placed the Matomo files. When you do, it automatically starts the installation process.
The first part is the welcome screen. There is nothing to do here but click Next.
In the next screen, the installation will perform a system check. This makes sure your environment is suitable to run the analytics software.
Check if everything is fine here and correct what is not, then click the Next button at the bottom again.
Connect to MySQL
After that, it is time to connect to the MySQL database. As mentioned, for that you need the server where it is located, the username, password, and database name. Input all of that into the form on the page.
In addition, you may want to configure a custom table prefix for security’s sake. You can ignore the Adapter section. It will only become relevant in case there is a problem.
When you hit Next, and everything is configured correctly, Matomo will now create the database tables and give you a success message.
There is nothing to do here than move on to the next point.
Create an Admin Account
In this step, you will set up your administrator account.
Input a username, your desired password twice, and an email address. You can also opt in to the Matomo newsletters if you want. Once you have set it all up, it’s time to move on to the next step again.
Create a Website Property
Here’s where you set up your first property, meaning the website you want to track traffic on.
Input a name under which you want to save the website and its URL. Then, pick a time zone and whether it is an e-commerce website or not. You can edit all of this later, so don’t worry if you make a mistake.
Click Next when you are done.
You can copy and save it somewhere as you will need it soon, however, you can also access it later and there are ways to do without it, so it’s not really critical. There are also a bunch of helpful tips and alternatives to using the tracking code on this page.
After that, you can move on to last step. It is simply a congratulatory message with next steps and the possibility to take you to the login page of your newly installed Matomo analytics.
However, for now we are done here. The Matomo setup is not so different from when you install WordPress, is it?
2.4 Log Into Matomo for the First Time
For the next step, you need to log in to Matomo. For that, simply access the address where you installed the analytics software (or use the button on the last page of the installation). When you do, you will see a login page.
Here, enter the username and password that you set up during the installation process. You will be confronted with a message that tells you to connect Matomo with the website you want to track traffic on.
That’s exactly what we will do now, so we are way ahead of them. You just need to be sure that you are able to successfully log in first because you will need some information from inside Matomo.
2.5 Add the Tracking Code to Your Website
To start tracking, you need to add a code snippet to your website. However, if you are planning to import your existing Google Analytics data (see below), I advise that you do that first. I had some difficulties with Matomo automatically creating new properties/websites upon import, which meant that my newly tracked data and the imported information were not in the same place initially. For that reason, I advise that you first start the import and then add the tracking code. This way, you can directly connect your site to the web property your data is being imported into.
As for adding the tracking code, you can do that in several different ways. For example, you can simply add it to the
header.php file of your WordPress child theme. Just copy the parent theme’s header file, open it in a code editor, and paste the code right before the closing
The downside of this method is that, if you change the code snippet in the future, you will have to replace it manually. For that reason, and to be more beginner friendly, it can be a good idea to use a plugin instead.
Using a WordPress Plugin
A good option here is WP-Matomo Integration. It can both add the tracking code, offers configuration options, and can also show Matomo data in the WordPress dashboard after you install it. You can simply add and activate it via Plugins > Add New in the WordPress dashboard.
After that, go to the settings under Settings > WP-Matomo to establish a connection to your Matomo installation.
For that, leave Matomo Mode as is and enter the URL where the Matomo installation resides under Matomo URL.
After that, you need to enter an Auth token. You find that in the Matomo settings (which is why we tested whether it’s possible to log in earlier). So, go back to your Matomo installation, then click the gear symbol at the top right and go to Personal > Security. Here, you find the option to create Auth tokens at the bottom.
Click on Create a new token, confirm by entering your password, then enter a description for what you are using it for.
In the next screen, you will then see your token (you usually should not expose this information to anyone but this is on a local test website so it doesn’t matter).
Make sure to copy it as there is no way to view it again later, you would have to create a new one instead. Then, paste it into the respective field of the plugin configuration.
Finish the Setup
If you have more than one website connected to your Matomo install, be sure to uncheck the box for Auto config. That way, the plugin will let you choose which property this website belongs to. Otherwise, if you only have one, it will use that one.
When you’re all done, click Save Changes at the bottom. If you have configured everything correctly, you should see a new Enable Tracking menu.
Here, you need to start tracking by picking Default tracking from the drop-down menu (tracking is deactivated by default). Save at the bottom and you are done.
There are a few more configuration options that make sense to look at:
- Tracking code position — Decide whether to place the tracking code in the header or footer. The latter can be a good idea for performance, however, Matomo generally recommends the former.
- Track search requests — See what users type into your site’s search form. This is useful to know what else they would like to see on your site.
- Note for new content — Here, you can activate that Matomo will automatically add a note to your tracking data when you publish certain content. This will show up in the analytics so you can understand, for example, if your traffic increase is due to a new blog post.
- Disable cookies — If you want to use Matomo cookie free, use this option. I will discuss whether that’s a good idea or not and its consequences further below.
- Tracking filter — Here, you can determine which user roles you don’t want to track when they are logged into your site.
Don’t forget to save your changes!
Show Analytics Inside WordPress
Under Show Statistics, you also have the possibility to enable Matomo statistics right inside the WordPress dashboard.
Among other things, you can configure the default date for the analytics, switch on a dashboard overview and its time range, a traffic graph, and who should be able to see these. You can also enable single-post stats, create a shortcut to the Matomo dashboard, and decide whether to enable shortcodes to show this data in your posts and pages. This is great stuff for a quick overview in WordPress without having to log into your analytics suite.
Using the Matomo Tag Manager
Another method to install the Matomo tracking code on your WordPress website is to use its tag manager. This is especially a good idea if you are planning to add other tracking snippets to your site such as for newsletter signups, popups, affiliates, ads, or else. A tag manager makes it much easier to configure all of these in a single place.
Matomo comes with this functionality built in and getting the respective code (called container) on your site works very similarly to adding just the tracking code. You find all of it in the settings under Tag Manager in the top menu of your Matomo installation.
However, there is a lot more to using a tag manager, which is outside the scope of this Matomo tutorial. For that reason, if you want to learn more about this feature, check the Matomo documentation.
Add More Websites to Matomo
As mentioned, a cool thing is that if you want to track more than one website with a single Matomo installation, you can do so. That way, just like in Google Analytics, you can view all of the data for your websites in the same place. It’s also pretty easy: Simply go to All Websites in the top menu, then click Add a new website in the list that opens.
This will take you to the settings and Websites > Manage > Add a New Measurable, so you can also take this path directly if you want.
It first will ask you to pick whether you are adding a website or intranet website. When you have made your choice, it takes you to a form to fill out.
Here’s the information you need to enter:
- A name that you want the website to appear under in Matomo
- The URLs that it is reachable under (there is no need to input the www-version as a variety, Matomo does this automatically)
- Whether to include URL parameters (like link jumps) in URL tracking
- IP addresses, parameters, and user agents to ignore in tracking
- Whether to track site search and what parameters to consider for that
- Whether this is an e-commerce site or not
- Disable the visits log and/or visitor profiles depending on your privacy laws
- Currency and time zone
Make your choices. When you hit Save, the new site will appear in the list of properties in your account (where you can also edit and delete it if you don’t need it anymore).
After that, when you go to Websites > Tracking Code, you find a new drop-down functionality to pick the website you want to see the tracking code for.
In addition, in the dashboard, you find a drop-down button to switch between which site data you want to see.
Everything else, such as connecting the second site to Matomo, works as described above.
Importing Existing Google Analytics Data
If so far you have been using Google Analytics for your tracking needs, you probably want to import your existing data. In order to do so, it needs several steps that I will go over now. Parts of this process is a bit technical but bear with me. You only have to do it once and if I can figure it out, so can you.
Note: Importing Google Analytics data into Matomo is the same whether you are using the plugin method or install and connect Matomo with WordPress manually.
1. Check the System Requirements
In order to be able to move your Google Analytics data to Matomo, your installation needs to meet a few requirements:
- You need to have at least Matomo version 3.12.0 (this is so you can use the importer plugin)
- Your PHP configuration needs to allow the use of
- Your server must allow the execution of CLI PHP from within a web request and must have
- The Matomo installation should have cron archiving set up (though it worked for me without)
Also, be aware that, at the moment, the Importer only works for older Google Analytics properties, whose IDs start with UA-. Google Analytics 4 properties or properties with different IDs are not yet supported.
2. Install the Google Analytics Importer Plugin
To import your existing tracking data, Matomo offers a dedicated plugin called Google Analytics Importer. There are several ways to install it but the easiest is to log in to your Matomo installation, go to the settings (gear symbol, remember?), and then Platform > Marketplace.
Here, search for the plugin by name in the lower right corner. Hit Install when it pops up and confirm the installation with your password.
Once done, activate the plugin.
3. Configure a Google OAuth Client
This next step is honestly a bit complicated and annoying but, unfortunately, mandatory. So, let’s go through it step by step and be done with it. I’ll try to compress it as much as I can. For more visual instructions, you can also use these slides that I put together (you can find the presentation here):
To import your data, you need to create the possibility for Matomo to access your Google Analytics data via API. For that, you have to create an application that enables this like so:
- Go to Google Cloud and log in with your Google account. At the top, choose My Project > New Project.
- Give the project a name that makes sense and that you will be able to recognize later (e.g. Matomo GA Data Importer), then click Create.
- When done, open My Project in the taskbar on top again and click on your new project name in the list.
- Use the search bar at the top of the screen to look for “Google Analytics API”. It should appear first in the list with an API icon to the left. Click it, then choose Enable in the next screen.
- Repeat step 4 with the “Google Analytics Reporting API”.
- Next, search for “oAuth Consent Screen” and click on it when it appears. Here’s how to configure it:
- On the first screen, for User Type, pick External and hit Create
- In the next screen, provide an app name and choose your email address under User support email. Fill in the same address under Developer contact information.
- Where it says Authorized domains, click on the Add Domain button and input the top-level domain where your Matomo installation resides (meaning without a subdomain or folder).
- When done, click Save and Continue.
- In the following screen, click Add or Remove Scopes. This will open up a slide-in window, click through the list until you see the Google Analytics API with a readonly scope (it says …/auth/analytics.readonly in the Scope column). Tick its checkbox, click Update at the bottom, then Save and Continue on the main page.
- In the next screen, click Add Users, enter the email address you use to access your Google Analytics data and click Add, then Save and Continue again. In the final screen, hit Back to Dashboard.
- On the left, choose Credentials, then Create Credentials at the top and pick OAuth client ID from the drop down.
- In the next screen, for Application Type, choose Web Application and input a name, e.g. something that allows you to understand which website this is for.
- Where it says Authorized redirect URIs, you also need to add your Matomo URL but then add /index.php?module=GoogleAnalyticsImporter&action=processAuthCode at the end of it.
- Click Create when both of these are present.
- In the final step, you will be presented with a client ID and secret for your OAuth client. Click on Download JSON to download the configuration file. That’s it for this part (thank god!).
4. Connect Google Analytics to Matomo
Now it’s time to connect your new OAuth client to the Google Analytics Importer plugin. For that, go back to Matomo’s settings menu, then System > Google Analytics Import and click the Configuration File button. Then choose the file you just downloaded.
Hit Save when you are ready to get to the screen below.
Here, click Authorize, then follow the prompts by Google to grant the required access. It might tell you that the app hasn’t been verified and that’s fine. Be sure to click Continue here and not Back to Safety.
After that, we are done here as well.
5. Start the Import
Once authorized, the Google Analytics Importer plugin offers you a new form in which can configure your data import.
Here’s how to fill it in:
- Start Date — The date from which you want to start importing data. It defaults to when you created your Google Analytics property. You can also use this to limit the time frame if, say, you only need the last two years or so. The date format for this field is YYYY-MM-DD.
- End Date — Date at which to stop importing. Usually the time when you activate Matomo (actually, one day before) so as not to mix your data. If you don’t input anything there, the import will run until you stop it.
- Google Analytics Property ID — This is your tracking ID. You find it in Google Analytics under Admin > Property > Tracking Info > Tracking Code and it looks something like UA-12345678-9.
- Account ID — You find this in Admin > Account > Account Settings in the upper right corner. It’s an eight-figure number that’s often the same as the middle of your property ID (but not always, so check).
- View ID — The ID of the view you want to import. In Google Analytics, a “view” is a particular set of (filtered) data. By default, it is “All Website Data”. The ID is, again, a number and you can find it in Admin > View > View Settings.
- Mobile App — Check this box if the data you are importing is for a mobile app, not a website.
- Timezone — This is only important if your Google Analytics installation uses a timezone that’s not valid in PHP. In that case, you can set a custom one here.
- Extra Custom Dimension Mappings — Allows you to import certain dimensions (meaning data) that are not available in Matomo into a custom dimension.
- Ignore Custom Dimensions Slot Limit — If your Google Analytics property uses more dimensions than Matomo accommodates by default, you can tell it to ignore that limit here.
- Troubleshooting — In this place, you can enable detailed logging to find the issue if your import fails. Only use it if there is an actual problem because it results in a lot of data output.
Once you have input all the necessary information, hit Start at the bottom. If all goes well, you will see a new entry in the Import Jobs list at the bottom.
The import should now be running. Come back here and refresh the page to see its updated status.
6. Wait Until It Finishes
After this, it’s a bit of a waiting game. Depending on how long you have been using Google Analytics and how long your import frame is, there might be a lot of data to transfer, which will take a while.
In addition, Google places a limit on API requests per day (max 50,000). This is about four months’ worth of data (if every day has data) and uses up in a couple of hours. For that reason, the import will probably last at least a few days.
Another thing to keep in mind is that the OAuth client we created will automatically lose authorization after a week. After that, it has to be re-authorized. This isn’t hard (simply click the Re-authorize button in the Matomo Importer settings page and follow the instructions) but it is something you need to keep in mind.
You can get around that by temporarily purchasing a Google Workspace account and creating an internal app instead of an external one (see the OAuth Consent Screen settings). If that’s something that makes sense for you (e.g. because you have to import several years worth of data), it doesn’t cost the world and there is even a 14-day free trial.
Check back in with the importer page regularly and delete the job when it is done. Also, when the import is finished, make sure to back up your Matomo database (instructions below). That way, if something happens, you don’t have to do the whole thing again. Plus, if you delete your Google Analytics account in the meanwhile, you might lose all your data forever.
Matomo Configuration – Correctly Set Up Your Analytics
Alright, now that you have successfully managed to install Matomo and connect it to your WordPress site, it’s time to configure it. Here, the most important part are the privacy settings. While Matomo is very privacy-friendly out of the box, there are still a few things you need to configure.
Part of the update is also to give visitors the ability to opt-out of tracking. This means that you add a checkbox to the privacy page where they can switch off being tracked on your site.
How you get it there depends on your method of installing Matomo in WordPress in the first place.
Using the WordPress Plugin
The block doesn’t have any settings, it just says it’s name on the page. However, when you preview the page or publish and view it, you can see that it inserts a check box where visitors can opt out of tracking as well as accompanying text that changes depending on whether they are currently opted in or out. This way, visitors can determine whether they want their visits to be recorded or not. The text will also tell visitors who have DoNotTrack enabled in their browser that your site is honoting their wishes (if that’s how you configured Matomo).
The block will automatically display the message in whatever language the user browser is set to. Alternatively, you can also use the
[matomo_opt_out] shortcode to add it to the page. Here, you are able to set your preferred language by including it in the shortcode like
[matomo_opt_out language=de]. Available languages here.
Manually Add the Matomo Opt-Out Option
If you set up Matomo without the help of a plugin, adding the opt-out is not that much more complicated. In that case, go to your Matomo installation, then to the settings and Privacy > Users opt-out. Here, you find options to configure the opt-out form and copy the code to get it onto your site.
Use the controls at the top to change the font and background color, font size, and font family to your needs. Tip: you can copy the font-family information straight from your site with the web developer tools. Unfortunately, the color pickers don’t take hex colors, so it’s a little more complicated than it has to be.
When you are done, copy the iframe code on the page and insert it into your WordPress page using the Custom HTML block (it’s easiest to insert via /html).
Unfortunately, even if you use the customization options, the opt-out section still usually does not come out looking like it belongs on your site, especially in mobile because the font size does not adjust.
Some tips for a better result:
- The code contains a fixed width and height (the part after
style=). It might look better if you delete the height and set width to
100%so that it goes across the entire page.
- Use the
Unfortunately, because it is using an iframe, there is not much else you can do. There are ways to build your own opt-out widget but that is outside of the scope of this article (it is getting long enough as it is). There is also this plugin, which says it allows you to add custom CSS to the opt-out form but I haven’t tried it out yet. Plus, you are supposed to be able to customize the text in the opt-out with this plugin.
2. Additional Matomo Privacy Settings
Alright, after the opt-out option, let’s have a look at the other privacy settings that Matomo has to offer.
Here, you have the option to make a lot of the data that Matomo tracks anonymous. At the top, you can exclude or mask IP addresses from being tracked in Matomo.
Decide how many bytes you want to anonymize or fully mask your visitors addresses. Note, however, that the more you mask, the lass accurate your location data will be.
In addition, you can control the use of anonymized IP address in plugins that offer richer user data, replace user IDs with pseudonyms to obscure the data further, anonymize order IDs for online shoppers, and force Matomo to track without any cookies (more on that soon). Furthermore, you can remove data from referral domains and make them more or completely anonymous.
At the bottom, you also have the opportunity to set a time interval when Matomo should delete old raw data and reports aggregated from it. Finally, you may apply anonymization to data that you have previously tracked. Your decisions here depend on what your local laws require you to do.
We already talked about this menu as this is where you find the code to add the opt-out option to your site. It also includes an additional setting whether or not want you want to honor DoNotTrack requests from browsers. It is switched to yes by default and it’s a good idea to leave it like that in order to adhere to the wishes of your visitors.
Asking for Consent, GDPR Overview, GDPR Tools
The the last three privacy options for Matomo don’t really contain settings but additional information.
- Asking for Consent — This part only links to blog posts on asking for user consent.
- GDPR Overview — A checklist for what you need to do in order to be GDPR compliant. It is broken down into several categories and has useful links to different relevant parts of the Matomo user interface as well as blog posts and articles on important aspects.
- GDPR Tools — This screen allows you to search for data you have on different users on your website. This comes in handy if someone requests to see what kind of information you have collected about them or asks you to delete them. Both something you need to provide under GDPR, that’s why this function exists.
3. Configure Matomo Settings
Aside from privacy settings, Matomo offers a number of other options in the settings menu.
Here’s what they contain:
- Personal — Configure email, language, and time format, set which data reports should be visible on the dashboard by default and their time frame. The most interesting setting here is that you can have Matomo set a cookie in your browser that keeps your own activity from being tracked on your website. You can also change your password and set up two-factor authentication as well as Auth tokens as discussed above. Email Reports allows you to configure automatic email reports sent to you, what data they contain, and when and how you want to receive them.
- Websites — Manage the websites that you are using Matomo on, exclude IPs, query parameters, and user agents from being tracked as well as switch on parameter tracking (e.g. for link jumps). What’s more, you can decide to track internal site search and set up default timezones and currencies for new websites. As mentioned, this is also where you can find and configure the tracking code as well as set up goals and custom dimensions to track on your site. The menu also has instructions for how to increase the number of custom dimensions (there are only five available by default).
- Platform — Here’s where you find the plugin marketplace where you can find and install Matomo plugin (including premium extensions). It also lets you configure dashboard widgets and who can see them. Plus, you are able to copy code snippets to display your dashboard and widgets in an iframe anywhere else. Finally, you find access and explanations for the Matomo API in this place.
- Diagnostic — Last on the list, this menu contains the Matomo system check, a list of failures it experienced, the current configuration, an a log of blocked IPs that tried to brute force their way in. Under Device detection, you can check whether Matomo correctly sniffs out user devices.
How to Use Matomo Without Cookies
One of the draws of Matomo is that you are able to use it without cookies. That also means, you don’t need to use a cookie banner, which have become somewhat ubiquitous around the web.
So, how can you do this? And most importantly, should you?
(Quick note: I am not a lawyer, nor do I play one on TV. Therefore, none of the advice here should be considered legal advice. I am trying my best to compile accurate information here but please don’t try to sue me if I get something wrong.)
1. How Does It Work (And Is It a Good Idea)?
As mentioned, the benefit of this setup is that you no longer need a cookie banner, at least not for Matomo. If you have other software on your site that sets cookies, you still need one for that. Same if you are using Matomo for e-commerce or switch on its User ID function.
At the same time, using Matomo cookieless will also have effects on your tracking:
- Your unique and return visitor numbers will be less accurate as, without cookies, it’s harder to track if someone was on your site before or not. Same goes for things like days since last visit or the number of visits until a conversion occurred and other smaller reports.
- The situation is similar for goal and conversion tracking. If users don’t enter your site through links with tracking parameters on them, they will always be attributed to the channel that they used in the session they converted, even if they originally came to your site in a different way.
2. Disabling Cookies in Matomo
Setting up Matomo without cookies is relatively easy. Inside the settings of your installation, go to Websites > Tracking Code. Scroll down to the Advanced section and click on Show.
In this menu, you find some new options. One of them says Disable all tracking cookies. When you click it, it updates the tracking code above to include a new line that says
This disables tracking cookies for Matomo. However, it won’t have any effect on your site unless you also include it in the tracking code you are using. How you do that, depends on what you used to install Matomo on your WordPress website.
Update the Tracking Code Manually
If you handle your tracking code by hand (e.g. by copying it into your (child) theme’s
header.php) you can copy the entire updated tracking code and replace what you have on your site. Be careful, as disabling the tracking cookie is reverted when you reload the settings page, meaning you need to switch it on again.
Alternatively, can also only manually input the one line that is responsible for disabling cookies, which is this:
It belongs in the place indicated in the screenshot above, right above
_paq.push(['trackPageView']);. The Matomo tag manager offers its own settings for disabling cookies.
Disable Matomo Cookies Inside Plugins
If you are using a WordPress plugin to install Matomo, it’s even easier. In the official Matomo Analytics plugin, you find the option under Matomo Analytics > Settings > Tracking.
Simply check the box where it says Disable cookies, save your changes at the bottom, and you are done. The plugin should automatically update the tracking code on your site.
If you installed Matomo separately and are using the Matomo Integration plugin to connect to it, this option is available under Settings > WP-Matomo > Enable Tracking.
(Note that you might have renamed WP-Matomo to something else, so the path might be different for you. In addition, this option is only available when using standard/default tracking, not manual tracking. In the latter case, you need to add the line yourself.)
Again, check the box and save, done.
3. Empty Cache and Check if It’s Working
If you are using any type of caching on your WordPress site, make sure to empty it after making the changes above. If you don’t, your site might still serve up the old tracking code, which sets cookies.
To check if it worked, open the developer tools of your browser (Ctrl/Cmd+Shift+I in both Firefox and Chrome) and go to the Storage menu (under Application in Chrome). Here, you can see all the cookies that the current page sets.
Reload it with Ctrl+F5 (to empty your browser cache), then check what it says there. You can find list of all Matomo cookies here. None of them should show up except maybe
matomo_sessid. These have to do with the opt-out features for both users and admins who don’t want to be tracked on the website.
What Does Matomo Track? Understanding Your Website Traffic
At this point, we have arrived at the stage where we can talk about what exactly you can find out with Matomo. After you install it and connect it to your WordPress site, the analytics suite will start recording your traffic and giving you information about it. Let’s find out what Matomo tracks and how it can help your with your knowledge about your audience.
As mentioned earlier, if you used either of the two WordPress plugins above to install and/or connect Matomo with your site, you will be able to see some of your analytics data in the back end. I already covered this for the Matomo Integration plugin. When using the official Matomo plugin, you find it under Matomo Analytics > Summary.
Everything you see here, you can also pin to the WordPress main dashboard by clicking the little icon in the upper right corner.
If you want more information, you have to head on over to the Matomo dashboard. It is what you see when you go to your Matomo installation and log in. It looks a lot like Google Analytics with detailed reports about different aspects of traffic on your website.
The dashboard gives you a summary of things like real-time visits, visits over time, movers and shakers (meaning pages that are performing exceptionally well or have great changes), an overview of your visits (duration, pageviews, etc.), a map where your visitors are located, and the channels from which they came.
Hover over each widget title to drag and move, refresh, minimize, maximize, or remove it from the dashboard. Some widgets also offer extra configuration options when you do.
That way, you can customize the Matomo dashboard exactly to your needs. In addition, at the top you are able to change the date range and user segment that you are looking at.
The button that says Dashboard enables you to add more widgets, manage the existing dashboard (e.g. change its number of columns, rename, and reset it), as well as create a new dashboard. If you do the latter, it will show up under Dashboard in the left menu.
In short, the Matomo dashboard is completely customizable to show exactly what you need and deliver information that is relevant to you and your website. Let’s now look at single reports.
On the left side, Matomo offers number of links to reports on different categories. Here’s what they contain:
- Visitors — Visits over time and visitor overview. You also find a log that saves information about individual users and allows you to access their profiles. Check real-time visits and the real-time map, the locations that visitors are from and the browser language, operating systems, and devices they use. You can also find out the times they most visit and have a user ID report if you have enabled them.
- Behavior — Visited pages, entry and exit pages, keywords visitors search for on your site (if enabled), and outlinks they click on. You can also check the number of downloads, events that you are tracking as well as content interactions, and user engagement. The last part means returning visitors, how long they stay, how many pages they visit, etc. The report also shows how visitors move across your site, and – very important – page performance.
- Acquisition — Basically, this part shows how visitors are coming to your site, what channels they use (search and what keywords, referral, social, campaigns), and breakdowns for all. It also has a tracking URL builder that you can use to measure the effectiveness of different campaigns.
- Ecommerce — When you are using e-commerce tracking, Matomo measures things like orders, revenue, and abandoned carts. It also has an e-commerce log that tracks every action of a visit, shows the performance of single products and categories, and has a detailed breakdown of sales happening on your site. That way, you can analyze what works and what doesn’t.
- Goals — Here, you can define goals and see how your existing goals are performing.
Within the reports, too, you can naturally adjust the time frame and user segmentation. If you are ever unclear about what a certain report says, hover over its name in the left-side menu and click on the question mark that appears. When you do, a helpful description will appear at the top.
Overall, Matomo is very reminiscent of the older Google Analytics, before Google Analytics 4 came out.
Backing Up Matomo – How to Protect Your Analytics Data
When self-hosting your own analytics solution, one thing that is different to using something like Google Analytics is that you are also responsible for backups. The server is owned (or at least rented) by you and if something goes wrong with it, it’s up to you to make sure that you are able to recover. Unfortunately, with Matomo there is no super comfortable solution for that.
What Needs Backing Up?
The first things to note is that, similar to WordPress, the most important stuff is what is in the database. Here’s where Matomo saves all your tracking data, so if the database goes, so does your data.
The file system, on the other hand, is mostly what you can always download again from the Matomo website. The only things you might want to save here is the configuration file under matomo/config/config.ini.php and any plugins under matomo/plugins/. Aside from that, as mentioned, backing up Matomo is all about saving the database.
How to Do It
If have you used the official WordPress plugin to install Matomo, you will automatically save your analytics data with any backup solution you have in place for your site. It is part of the WordPress database, which usually gets backed up whenever you create a copy of your website.
When you have Matomo in a standalone location, you need to manually back up the database. For that, most hosting providers offer a solution like phpMyAdmin that allow you to export and import it.
The unfortunate thing here is that you need to remember to do it yourself, there is no native solution to make it happen automatically. While there are ways to do this, e.g. via a bash script, this is honestly a bit beyond my skill set.
Doing it with phpMyAdmin is easy enough. Log in and navigate to the database you want to save, then click on Export at the top.
Leave Export method as Quick, make sure Format says SQL, and click Go. This should prompt a download. Save the file and wait until the download has finished.
Don’t forget to access your Matomo server via FTP and download both your plugins and the config file mentioned above. You now have backed up Matomo to your hard drive, well done!
How to Upgrade Matomo to the Latest Version
In the final part of this Matomo installation guide for WordPress users, I want to talk about upgrading Matomo. Like other open source projects, it is constantly being developed and improved. Updates bring bug fixes, security upgrades, and new features and functionality.
To find out if an update is available, first check your dashboard. Matomo will automatically check for updates and give you a notification when a new one has come out.
Alternatively, go to the settings section where you find a button at the top that says Check for Updates. Click it to have Matomo check whether there are any new versions. If there is, you have two ways to update Matomo to it.
Using the Automatic Update
Like WordPress, Matomo offers an automatic process to install a new version. Before taking advantage of it, make sure you have created an update as described above. After that, all you have to do is click on the update message in the Matomo back end and then choose Update Automatically in the menu that follows.
The automatic update will then start and process until it’s done.
That’s it, after it finishes, Matomo should be on the latest version.
Manually Updating Matomo
Alternatively, you can also update Matomo by hand. This, too, is similar to how it happens in WordPress.
- Back up your Matomo installation, especially the config file and database.
- Download the latest version of Matomo and unzip the archive.
- Connect to your Matomo installation via FTP and start uploading the new files. Make sure to confirm that they should overwrite the existing files.
- When finished, log back in to Matomo. You should see a prompt to update the database. Answer in the affirmative. This may take a little while. Don’t close the browser window while it is working!
- After it is done, the update is complete. Make sure to swing by Diagnostics > System Check in the Matomo settings to see if there are any problems after the update.
As you can see, it’s not too complicated. You can find the FAQ for updating Matomo here.
Final Thoughts: Installing Matomo in WordPress
I admit, that was a handful. The post turned out quite a bit longer than I initially thought. However, with privacy laws changing, it’s important to be aware that there are alternatives to Google Analytics. Especially if your local legislation demands you to change.
Matomo is one of the most successful Google competitors and for good reason. It has a nice feature set that makes it a great and free web analytics solution should you want or have to switch.
Above, we have gone of the process of installing Matomo in your WordPress website. Whether you choose the official plugin or manually set up Matomo in an entity separate from your main site is up to your specific needs and circumstances. Both are absolutely doable.
Granted, the process of importing your Google Analytics data is a bit complicated but if I managed to do it, I am confident that you can, too. After that, make sure to run through the process of configuring Matomo in a privacy-friendly way, otherwise what was the point? You also have the option to use it completely without cookies and find instructions for how to do so above.
Finally, you now also know how to back up and update your Matomo installation to keep it safe. Welcome to the new age of privacy-friendly user tracking! I hope it works well for you.
Which method did you choose to install Matomo in WordPress? Let me know in the comments below. I’ll also do my best to help you troubleshoot if you run into any problems.