How to Install Matomo Analytics

Installing Matomo Analytics is straightforward and adaptable to various tracking setups. Whether you’re a developer managing a large-scale project or a marketer integrating analytics without writing code, Matomo offers multiple methods to get started. This guide covers three popular ways to install Matomo: using the JavaScript tracker, Matomo Tag Manager, and Google Tag Manager.


Before You Begin

Prerequisites:

  1. Access to your Matomo installation (cloud or on-premises).
  2. Administrator or editing rights to your website or app.
  3. Basic familiarity with your website’s code or tag management system.

Option 1: Using the JavaScript Tracker

The JavaScript tracker is the most direct way to set up Matomo Analytics. It involves embedding a tracking script in your website’s HTML.

Step-by-Step Instructions:

  1. Access Your Matomo Dashboard
  • Log in to your Matomo installation.
  • Navigate to the Administration section and select Websites > Manage Websites.
  1. Get the Tracking Code
  • Add your website to Matomo if you haven’t already.
  • Copy the JavaScript tracking code provided for your website.
  1. Paste the Code on Your Website
  • Place the script just before the </head> tag in your website’s HTML file.
  • The basic script looks like this:
    javascript ¨K13K
  • Replace your-matomo-url with your Matomo installation URL and setSiteId with your website’s unique ID.
  1. Test the Installation
  • Visit your website and check if data appears in the Matomo dashboard. Use your browser’s developer tools (Network tab) to confirm that matomo.php is loading without errors.

Option 2: Using Matomo Tag Manager

If you prefer a more centralized way to manage tracking codes, Matomo Tag Manager simplifies the process and allows for flexible configuration without modifying your website’s code repeatedly.

Step-by-Step Instructions:

  1. Enable Matomo Tag Manager
  • In your Matomo dashboard, go to Tag Manager and create a new container for your website.
  1. Configure the Container
  • Add a new Tag:
    • Choose the Matomo Analytics Tracking Tag template.
    • Set the Site ID and Tracker URL (same as in the JavaScript tracker).
  • Add a Trigger:
    • Use the Page View Trigger template to fire the tag on all pages.
  1. Publish the Container
  • Save your changes and publish the container.
  1. Add the Tag Manager Code to Your Website
  • Copy the Tag Manager container code from Matomo. It looks similar to:
    javascript ¨K16K
  • Replace your-matomo-url with your Matomo installation URL.
  1. Test the Installation
  • Publish the changes, visit your website, and verify data collection in the Matomo dashboard.

Option 3: Using Google Tag Manager

If you’re already using Google Tag Manager (GTM), you can integrate Matomo without adding any additional scripts to your website.

Step-by-Step Instructions:

  1. Create a New Tag in GTM
  • Log in to your Google Tag Manager account.
  • Open the container for your website.
  • Create a new Custom HTML Tag.
  1. Add the Matomo Tracking Code
  • Paste the JavaScript tracker code (as shown in the first method) into the Custom HTML Tag.
  • Configure the Tracker URL and Site ID as required.
  1. Set Up a Trigger
  • Add a Page View Trigger to fire the tag on all pages.
  1. Publish the GTM Container
  • Save and publish your changes in Google Tag Manager.
  1. Test the Installation
  • Use the GTM Preview Mode to confirm the Matomo script is firing on your site. Verify data in the Matomo dashboard.

Comparing Installation Methods

MethodProsCons
JavaScript TrackerDirect and simple setup.Requires manual updates for script changes.
Matomo Tag ManagerCentralized management, version control.Slightly steeper learning curve for non-developers.
Google Tag ManagerIdeal for users already on GTM.Adds a dependency on Google’s ecosystem.

Tips for a Successful Installation

  • Double-check URLs: Ensure that the Matomo Tracker URL is correct, especially if your installation is self-hosted.
  • Test after setup: Always verify that the tracking is working correctly using tools like browser developer tools or network monitoring.
  • Document changes: If using tag managers, keep a log of changes for troubleshooting and audits.
  • Regular maintenance: For on-premises installations, keep your Matomo instance updated to access the latest features and security patches.

Final Thoughts

Installing Matomo Analytics is a flexible process that adapts to your technical environment and preferences. Whether you prefer direct JavaScript implementation or the convenience of a tag management system, Matomo offers robust options to ensure reliable tracking.

Take the time to test and optimize your setup, and you’ll have a solid foundation for collecting accurate, actionable data to drive your business decisions.