Analytics

Matomo Setup Guide: Self-Hosted, Matomo Cloud and Tag Manager (Step by Step)

In short: to set up Matomo, choose Matomo Cloud (hosted for you) or the free self-hosted version (on your own server). Self-hosted means: create a MySQL/MariaDB database, upload Matomo, run the web installer, add the tracking code (or Matomo Tag Manager) to your site, then set up the archiving cron job so reports stay fast.

Matomo is an open-source analytics platform. Many businesses use it next to, or instead of, GA4 because the data can stay on your own server and it can run in a cookieless mode. Below is the setup I follow for clients. If you’d rather have it done for you, see my Matomo setup service.

1. Self-hosted or Matomo Cloud?

Self-hosted (Matomo On-Premise)Matomo Cloud
Who runs the serverYouMatomo
Software costFree (open source)Monthly subscription
Data locationWherever your server isMatomo’s hosting
Updates and backupsYouMatomo
Best forFull control, strict data rules, technical teamsFast start, no server work

If you don’t have someone to maintain a server, start with Matomo Cloud. If data must stay on your own infrastructure, self-host.

2. What you need for a self-hosted install

  • A web server with PHP and a MySQL or MariaDB database (shared hosting with cPanel works for small and medium sites).
  • An HTTPS domain or subdomain, for example analytics.yourdomain.com.
  • Access to set up a cron job.

Check the current requirements on matomo.org before you start; they change with new Matomo versions.

3. Install Matomo (self-hosted)

  1. Create a database and a database user in your hosting panel. Give the user full rights on that database only.
  2. Download the latest Matomo from matomo.org and upload the files to your subdomain folder.
  3. Open the subdomain in your browser. The installer checks your server, then asks for the database details.
  4. Create the super user (use a strong password and turn on two-factor authentication after install).
  5. Add your first website (name, URL, time zone, currency).
  6. Copy the JavaScript tracking code shown at the end.

4. Add the tracking code to your website

You have three options:

  • Paste the code into the <head> of every page (or use the official plugin for your CMS, for example WordPress).
  • Matomo Tag Manager (built into Matomo): create a container, add a “Matomo Analytics” tag with an “All Pages” trigger, publish, then add the container code to your site.
  • Google Tag Manager: add the Matomo code as a Custom HTML tag that fires on all pages. This works, but keep consent rules the same as for your other tags.

After publishing, open your site and check Visitors → Visits Log in Matomo. Your visit should appear within a minute.

Matomo can track with or without cookies. Common setups:

  • Require consent before cookies: add _paq.push(['requireCookieConsent']); before tracking and call _paq.push(['rememberCookieConsentGiven']); when the visitor accepts.
  • Cookieless: add _paq.push(['disableCookies']);. Visits are still counted, but returning-visitor reports are less accurate.

Which one is allowed depends on your country and your legal advice. If you also run GA4, see my Consent Mode v2 guide so both tools follow the same banner.

6. Ecommerce and goals

  • Turn on Ecommerce in the website settings.
  • Track orders with trackEcommerceOrder on the thank-you page (order ID, revenue, tax, shipping), or use the official plugin for WooCommerce and other stores.
  • Create Goals for leads: form submit, booked call, phone click.
  • Always send the order ID so the same order isn’t counted twice when the page reloads.

7. Set up archiving (important for speed)

By default, Matomo builds reports when someone opens them, which gets slow on busy sites. Instead:

  1. In System → General settings, turn off “Archive reports when viewed from the browser”.
  2. Add a cron job that runs every hour, for example: php /path/to/matomo/console core:archive --url=https://analytics.yourdomain.com/

8. Security checklist

  • Keep Matomo updated (it has a one-click updater).
  • Use HTTPS and two-factor authentication.
  • Give clients “view” access only.
  • Back up the database regularly.

Frequently Asked Questions

Is Matomo free?

The self-hosted version (Matomo On-Premise) is free and open source. You pay for your own hosting. Matomo Cloud and some premium plugins are paid.

Can I run Matomo and GA4 together?

Yes. Many sites do. Load both through the same consent banner so they count the same visitors, and expect the numbers to differ a little because they measure sessions differently.

Can Matomo track without cookies?

Yes. Use disableCookies for cookieless tracking. Visits are still counted, but returning visitors are harder to recognise.

How long does a Matomo setup take?

A basic self-hosted install with the tracking code usually takes an hour or two. Ecommerce, goals, consent and Tag Manager setup take longer, depending on the site.

Do I need Matomo Tag Manager?

No. You can paste the tracking code or use Google Tag Manager. Matomo Tag Manager is useful if you want to keep everything inside Matomo.

Direct Implementation White-Label for Agencies

Need this implemented, audited, or white-labeled?

Whether you are an eCommerce brand owner fixing signal loss or a digital marketing agency needing a senior analytics engineer under strict NDA, I deliver 24–48h SLA turnaround with 8.5+ EMQ match rates.

✓ 24–48h Emergency SLA ✓ Strict Non-Solicitation & NDA ✓ 8.5+ Event Match Quality
Jobair Mahmud

Jobair Mahmud

AI-Driven Performance Marketing & Web Analytics Consultant

Helping eCommerce brands and marketing agencies trust their ads data, scale Smart Bidding, and eliminate wasted ad spend through bulletproof server-side tracking and PPC management.