Published in

4 min read

6 days ago

If you had a Google Analytics account before installing Matomo, good news, Matomo has a plugin to import Google Analytics data!

The release of Google Analytics 4 (GA4), and the subsequent depreciation of Universal Analytics, has caused a stir amongst webmasters, SEO experts, marketers and the likes.

Google’s Universal Analytics is the most widely used web analytics platform in the world, but from 1 July 2023, it will no longer process any new data. Google is now pushing users to set up GA4 tracking imminently.

If you’re like many and wondering if you should upgrade to Google Analytics 4, there are two key reasons why this might be a risk:

  1. GDPR violations: recent rulings have deemed Google Analytics illegal in France and Austria, and it’s likely that this trend will continue across the EU.
  2. Data loss: users switching to Google Analytics 4 can’t migrate their data from Universal Analytics.

To mitigate these risks, many organisations are looking to switch to a Google Analytics alternative like Matomo. This is an ideal option for organisations that want to take ownership of their data, get compliant with privacy regulations and save themselves the stress of Google deprecating the software they rely on.

First Step: Set up Matomo.

What we want

Suppose we have a web project on mysite.ext. We want to shove Matomo into a subdomain stats.mysite.ext.

To do this we trivially need to:

  • Configure a DNS record of type CNAME that makes the subdomain an alias of the main domain.
  • Install Matomo and expose it to https://stats.mysite.ext.

After creating that record, we move on to the second step.

Preparation

We create a ~/matomo folder with in it:

docker-compose.yml

version: "2"

services:
matomo:
container_name: matomo
image: matomo
ports:
- 8080:80
environment:
- MATOMO_DATABASE_HOST=matomo_db
- VIRTUAL_HOST=acerinox.com
networks:
- net
volumes:
- ./matomo-data:/var/www/html/
env_file:
- ./db.env
depends_on:
- matomo_db
restart: unless-stopped

matomo_db:
container_name: matomo_db
image: mariadb:10.8.2
command: --max-allowed-packet=64MB
networks:
- net
environment:
- MYSQL_ROOT_PASSWORD=inventa
env_file:
- ./db.env
restart: unless-stopped

networks:
net:
driver: bridge

MYSQL_PASSWORD=inventa2
MYSQL_DATABASE=matomo
MYSQL_USER=matomo
MATOMO_DATABASE_ADAPTER=mysql
MATOMO_DATABASE_TABLES_PREFIX=matomo_
MATOMO_DATABASE_USERNAME=matomo
MATOMO_DATABASE_PASSWORD=
MATOMO_DATABASE_DBNAME=matomo

As soon as we are ready docker-compose up -d.

We verify that our nice containers are running with docker ps.

If all is well, let’s move on.

Now, access to http://<server-ip>:<port>

Press Next and follow the instructions

Check the system verifications

Fill the boxes with the correspond data

Press Next after created the tables

Set an admin user

Fill the boxes with the website data

Add the matomo code to your website

Note: It is highly recommended to use a URL to obtain the data correctly. You can create the URL with cloudflare.

To fix this error, we need to add code to the persistant configuration.

Go to the terminal and edit the next file:

~/docker/matomo/matomo-data/config

Add this lines to [General] section:

trusted_hosts[] = "0.0.0.0:8080"
trusted_hosts[] = "example.com"
enable_trusted_host_check=0

Now we can login into matomo website

Now, we need to add our URL to Matomo to access from outside. Go to www.cloudflare.com and record new subdomain

in this case, we´ll use matomo.example.com

After that, we need to add our Public IP to access from outside and open the 8080 port in our router.

For migrate the data from google analytics to matomo, follow me and check the next medium story.

If you have enjoyed this article and would like to buy me a coffee ☕️follow this BuyMeACoffe Link

Post
Filter
Apply Filters