添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Matomo tag for server Google Tag Manager

Published
Jul 20, 2023
Also available in

Matomo, an open-source digital analytics platform, provides a robust suite of tools for tracking and interpreting user engagement on your website. Contrary to mainstream analytics tools, Matomo's primary strength lies in its commitment to user privacy. It allows organizations to gather and manage user data in a secure, self-hosted environment, thereby eliminating third-party data sharing. The second option of using Matomo is a cloud-hosted solution that runs on servers that use Matomo.

Matomo became even more popular because of Universal Analytics's shutdown and the rise of Google Analytics restrictions in a few European countries.

This article will describe how to set up a Matomo Advanced tag for your server Google Tag Manager container, show how it works, and describe its features.

How Matomo tag works Copy link to this section

Using Matomo’s Tracking HTTP API, stape’s Matomo tag sends HTTP requests to your Tracking URL with the data you've specified in the tag. Tag automatically parses event data in the server Google Tag Manager container and tries to map it to standard events or e-commerce tracking. If any event or other parameters are manually specified in the tag settings, the tag will prioritize these parameters.

Event set-up methods:

  • Inherit from client . The tag will automatically parse event data and map available data.
  • Custom . With the help of this method, you can track pageviews and other custom events by adding event category, event action, and event name.

Types of actions that server-side Matomo tag supports:

  • pageview
  • event tracking
  • e-commerce tracking
matomo tag for server-side google tag manager

Tracking URL - Tracking HTTP API endpoint, for example, https://your-matomo-domain.example/matomo.php

Matomo site ID - The ID of the website you want to set up tracking for. To find the tracking ID click on the gear button in the top right corner, click Websites, then manage and you will find the site ID in Manage Measurables table.

Auth token - AuthToken is used to set the correct IP Address. Available In Matomo under Settings > Personal > Security > Auth Token. Optional (if it isn't set, the IP & Region displayed in Matomo will be incorrect).

Enable E-commerce Tracking - tag will try to map ecommerce data.

Use Optimistic Scenario - The tag will call gtmOnSuccess() without waiting for a response from the API.

Event Parameters - here, you can specify which parameters you want to override.

Request Headers - add the request headers name and value you want to add to the Matomo requests.

Logs Settings - Specify whether the tag should write to the logs to stape.

How to set up Matomo tag Copy link to this section

2. The Matomo tag is not yet in the server Google Tag Manager template gallery. You can download it from GitHub and add it to your server GTM container by opening the template tab, clicking new, clicking three dots in the top right corner, and clicking import.

matomo tag

3. Create a Matomo tag and add the required fields: Tracking URL, Matomo site ID, and Auth token.

4. Add any parameter that you want to override. In my example, I want the Matomo tag automatically parse event data based on Data Client requests.

matomo server to server tag

5. If you want to track e-commerce data using the Matomo tag, you will need to either turn on a checkbox "Enable e-commerce tracking" (in this case tag will try to parse event data and map it to Matomo e-commerce objects. Ensure that you have proper e-commerce data in the sGTM). Or you can manually set up e-commerce tracking by selecting the custom event setup method. Ensure to add required e-commerce parameters, which are &idgoal=0, transaction ID, items, revenue (idgoal, ec_id, ec_items, revenue). Pay attention to items parameter that should be in a format of a JSON-encoded array of items.

matomo server-side e-commerce tracking

6. Add triggers to your tags and open debug mode in sGTM and Visits log (Visitors -> Visits Logs) in Matomo to verify the setup. You should see the tag triggered correctly in sGTM, and in the Visitors log, there should be records of any event or e-commerce order reported to Matomo.

matomo tag for server google tag manager 
matomo tag for server google tag manager 

Conclusion Copy link to this section

In conclusion, integrating a Matomo Advanced tag into your server Google Tag Manager container facilitates enhanced analytics capabilities while preserving user privacy. This detailed walkthrough has demonstrated the ease of setup and the expansive features offered by the tag.

Implementing this setup allows for a seamless and efficient data collection process, eliminating the need for third-party data sharing and thus ensuring superior privacy compliance. If you have any questions, don’t hesitate to contact us!

Host your GTM server at Stape