SQL Query on Matomo Database to Calculate the Number of Visits to Each Page

Useful WebsitesI’ve been using for just short of four years now and have been pretty happy with it.

I generally consume the data it holds via the eweb portal, but I was wanting to extract some data to manipulate recently, in a way that the web portal didn’t allow, so I did a little poking around the database to work out the syntax needed to query the database directly in mySQL.

The below query returns all pages for the specified date range (the first two highlighted variables at the top), sorted in descending order of number of visits; the third parameter is the id of the site for which you want the data:

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
SET @StartDate = '2023-01-01'; SET @EndDate = '2023-12-31'; SET @SiteID = 1; SELECT name ,COUNT(name) AS COUNT FROM matomo_log_visit LEFT JOIN matomo_log_link_visit_action ON matomo_log_visit.idvisit = matomo_log_link_visit_action.idvisit LEFT JOIN matomo_log_action ON matomo_log_action.idaction = matomo_log_link_visit_action.idaction_name WHERE matomo_log_visit.idsite = @SiteID AND type = 4 AND matomo_log_link_visit_action.server_time >= @StartDate AND matomo_log_link_visit_action.server_time <= @EndDate GROUP BY NAME ORDER BY COUNT(NAME) DESC;

Website Analytics With Matomo: Update

Useful WebsitesThis post is part of the website analytics with Matomo where I am taking a look at Matomo which bills itself as a Google Analytics alternative that protects your data and your customers’ privacy.

Your Matomo site will send an email to the super user email address when there are updates available. To instal the update click the link on the email:

Matomo upgrade email

Continue reading “Website Analytics With Matomo: Update”

Website Analytics With Matomo: Add a Site

Useful WebsitesThis post is part of the website analytics with Matomo where I am taking a look at Matomo which bills itself as a Google Analytics alternative that protects your data and your customers’ privacy.

Addin sites to Matomo is easy to do. Click the cog icon to open the administration site of Matomo. In the Quick Links section click Add a new website:

Matomo admin dashboard

Continue reading “Website Analytics With Matomo: Add a Site”

Website Analytics With Matomo: First Run

Useful WebsitesThis post is part of the website analytics with Matomo where I am taking a look at Matomo which bills itself as a Google Analytics alternative that protects your data and your customers’ privacy.

With Matomo installed it is now available for you to log in using your super user account. Navigate to the website and enter the credentials and click Sign In:

Matomo sign in page

Continue reading “Website Analytics With Matomo: First Run”

Website Analytics With Matomo: Install

Useful WebsitesThis post is part of the website analytics with Matomo where I am taking a look at Matomo which bills itself as a Google Analytics alternative that protects your data and your customers’ privacy.

With the zip file of the Matomo On-Premise downloaded you need to upload that to your website. Once you’ve done that navigate to the domain name where you should see the Welcome! screen.

Click Next to begin:

Welcome! page of the Matomo installation process

Continue reading “Website Analytics With Matomo: Install”

Website Analytics With Matomo: Prerequisites

Useful WebsitesThis post is part of the website analytics with Matomo where I am taking a look at Matomo which bills itself as a Google Analytics alternative that protects your data and your customers’ privacy.

The prerequisites for installing the on-premise version of Matomo are quite straightforward:

  • Matomo can be run on any operating system such as Linux (Ubuntu, RedHat, CentOS, Raspberry Pi OS, etc.), Windows, macOS Server or FreeBSD.
  • A webserver such as Apache, Nginx, IIS, LiteSpeed, etc.
  • PHP version 7.2.5 or greater (the previous major vrsion of Matomo will run on PHP version 5.5.9 through to PHP 7x).
  • MySQL version 5.5 or greater or MariaDB
  • PHP extension pdo and pdo_mysql or the mysqli extension.
  • A mySQL/MariaDB database.
  • A mySQL/MariaDB user with permissions to create/alter tables in the database.

If you’re running a high traffic site, there are some resources available covering recommended setup.

Full requirements are available here.

Website Analytics With Matomo: Download Software

Useful WebsitesThis post is part of the website analytics with Matomo where I am taking a look at Matomo which bills itself as a Google Analytics alternative that protects your data and your customers’ privacy.

You can download the on-remise version of Matomo by clicking the large green button on the < href='https://matomo.org/matomo-on-premise/'>Matomo On-Premise page:

Matomo software download link

On the next page, click the large green Download Matomo button and save the zip file.

Website Analytics With Matomo: What is Matomo?

Microsoft Dynamics 365 Business CentralThis post is part of the website analytics with Matomo where I am taking a look at Matomo which bills itself as a Google Analytics alternative that protects your data and your customers’ privacy.

Matomo says you can “[t]ake back control with Matomo — a powerful web analytics platform that gives you 100% data ownership”. It is a GPL licensed web analytics software platform giving you detailed reports on your website(s) and visitors, including search engines and keywords used as wel as their language and pages they visit or files downloaded.

Matomo is open source software which can be used via the Matomo cloud or an “on-premise” installation where you have it installed on your own servers. In this series I will only be looking at the on-premise version of Matomo. Using on-premise Matomo means all of the software is installed on your servers and all of the data is on your database server.

This is a major difference to using Google Analytics, which I did for a short time, where your tracking data is owned and controlled by Google and used for whatever they decide. With Matomo the data is on your server and you decide how it can be used and by who; you can therefore ensure you are fully GDPR and CCPA compliant (I am based in the UK where GDPR applies but my websites are hosted in the US where most of my visitors come from).

There is also the capability to extend with plugins with more than 70 plugins available on the Marketplace; some of the plugins are free, but others are paid premium plugins.

Tracking is enabled on websites by way of a JavaScript tag added to the bottom of each page. Matomo then records activity and aggregates the data to provide detailed web analytics reports about your visitors, page views, referrer information, search engine keywords and so on.

Website Analytics With Matomo: Series Index

Useful WebsitesI’ve used a few different tools for tracking visits to my sites for a while, moving on from one tool when they made it less useful or when it stopped working. More recently I have started using Matomo which bills itself as a Google Analytics alternative that protects your data and your customers’ privacy.

In this series I am going to take a look at what Matomo is and how it is implemented and used. If you’re reading this post directly on azurecurve|Rambings of a Dynamics GP Consultant it will automatically update, otherwise you will need to .

Website Analytics With Matomo
What is Matomo?
Download Software
Prerequisites
Install
First Run
Add a Site
Update