+91 88 00 563434 [email protected] Blog open-book Knowledge Base

Find Solutions in Our Knowledge Base

Install Matomo Self-Hosted Analytics on cPanel

You are here:
Sharing is Caring

Matomo, previously recognized as Piwik, is a software for website analysis that is free and open-source. It runs on a web server powered by PHP/MySQL. Matomo allows users to track and analyze online visits to multiple websites.

Installing Matomo using cPanel – Step by Step

1) Start by logging in to cPanel and locating the “File Manager” under the “Files” category.

Install Matomo

2) Download Matomo (formerly known as PIWIK) from the official website to your local device.

Install Matomo

3) Create a folder called “Analytics” by selecting the “Folder” tab in the cPanel’s “File Manager” menu. This folder will be used to store all the Matomo files.

4) Next, upload the downloaded Matomo zip file to the created folder.

5) Extract the contents of the Matomo zip file by right-clicking the file and choosing the “Extract” option.

6) Once extraction is complete, move all the files from the “matomo” folder located at /public_html/analytics/matomo to the /public_html/analytics folder.

7) For security purposes, you can now delete the following two files from the /public_html/analytics folder.

The right way to install Matomo.html

matomo-latest.zip

8) Navigate to the “MySQL Databases” in the cPanel portal under the “Databases” category. Here, create a database and a user specifically for Matomo analytics.

Install Matomo

9) Open your browser and enter your domain or IP address followed by the folder name (analytics) created in cPanel to begin the Matomo installation process.

<domain name>/analytics

or

IP-address/analytics

10) Once the folder is accessed in the browser, you will need to set up the “Wizard of self-hosted Google Analytics PIWIK”. 

Setting up the self-hosted Google Analytics PIWIK Wizard

1) Click on the “Next” button.

Install Matomo2) The Wizard will check for any dependencies required by the system to run and automatically install Matomo on your hosting server.

3) Next, you will need to provide the database details by updating the username and password fields accordingly, and then click “Next”.

Install Matomo

At this point, tables will be created in the database and populated if necessary.

5) You can create a super or admin user for Matomo under the “SuperUser” tab.

Install Matomo

6) Under the “Set up a Website” tab, you can add the website details for which you want to obtain tracking information.

7) Under the “JavaScript Monitoring Code” tab, you will find a tracking code. In WordPress, you will need to go to Appearance -> Theme options and select Header, where you can paste the tracking code.

8) You can now log in to Matomo using the credentials of the super or admin user to access the Matomo dashboard.

Migrating a Specific Website in Matomo to a Different Matomo Installation

A Matomo plugin can be used to migrate a particular website from one instance to another. After the migration, you will need to update the tracking code on your website. Additionally, ensure that the Matomo URL and Website ID are correct.

When you need to migrate a specific website from one Matomo instance to another:

1) If you want to transfer a customer’s website analytics data to an independent Matomo instance, you can set up a new Matomo instance for their website and migrate all their website data to the new Matomo instance. Once that is done, you can delete all their data from the old Matomo instance.

2) If you have multiple Matomo instances and need to consolidate them into a single Matomo instance for easier maintenance, you can migrate all your website data from the multiple instances to the selected Matomo instance by running the Migration tool on each Matomo instance that needs to be migrated. After the migration is complete, you will need to update the tracking codes to refer to the new instance URL and Website ID. You can then uninstall all the other Matomo instances.

Migrating Matomo from One Server to Another

If you need to move Matomo from one server to another, you will need to transfer the entire directory containing Matomo files and the database to another MySQL Server. Follow these steps to migrate the Matomo files and database to another server:

1) First, you need to export your MySQL database to a file using tools like phpMyAdmin or mysqldump. You can create a full copy of the MySQL database by running the mysqldump command.

$ time mysqldump --extended-insert --no-autocommit --quick --single-transaction MATOMO_DATABASE_NAME -uMATOMO_DATABASE_USERNAME -p > matomo_backup_database.sql

2) Compress this backup before sending it to the backup server.

$ tar zcf matomo-mysql-database-$(date +%Y-%m-%d-%H.%M.%S).sql.tar.gz matomo_backup_database.sql

3) Import the backup to the new server using phpMyAdmin or restore the database backup by running the following command, which will create Matomo tables in your database:

$ mysql MATOMO_DATABASE_NAME -uMATOMO_DATABASE_USERNAME -p < matomo_backup_database.sql

4) Download the same version of Matomo on the new server. During installation, provide the MySQL server, login, password, and table prefix so that Matomo can detect the tables, existing websites, and reports automatically.

5) If there is any change in the Matomo domain name, you will need to update the Matomo javascript tags on all the tracked pages.

6) If you have set up any auto-archiving crons on the old server, you will need to set up the same cron script on the new server.

Please note that when migrating Matomo from one server to another, visits will not be tracked.

If you need further assistance, please contact our support department. If you have any questions regarding this tutorial, please leave a comment in the section below. We are here to help!


Sharing is Caring

Leave a Comment

Table of Contents