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:
- Access to your Matomo installation (cloud or on-premises).
- Administrator or editing rights to your website or app.
- 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:
- Access Your Matomo Dashboard
- Log in to your Matomo installation.
- Navigate to the Administration section and select Websites > Manage Websites.
- Get the Tracking Code
- Add your website to Matomo if you haven’t already.
- Copy the JavaScript tracking code provided for your website.
- 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 andsetSiteId
with your website’s unique ID.
- 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:
- Enable Matomo Tag Manager
- In your Matomo dashboard, go to Tag Manager and create a new container for your website.
- 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.
- Publish the Container
- Save your changes and publish the container.
- 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.
- 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:
- 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.
- 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.
- Set Up a Trigger
- Add a Page View Trigger to fire the tag on all pages.
- Publish the GTM Container
- Save and publish your changes in Google Tag Manager.
- 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
Method | Pros | Cons |
---|---|---|
JavaScript Tracker | Direct and simple setup. | Requires manual updates for script changes. |
Matomo Tag Manager | Centralized management, version control. | Slightly steeper learning curve for non-developers. |
Google Tag Manager | Ideal 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.