Skip to content

Integration of Matomo, Google Analytics, or Piwik PRO

This guide describes how to configure analytics services for measuring website visitor numbers in the Mercury template.

In order to be able to use these settings optimally, advanced technical understanding and knowledge of HTML and CSS are helpful.

Setting the Matomo properties “matomo.url”, “matomo.id” and “matomo.jst”

To use Matomo, you have to specify the URL of the Matomo server you are using. In OpenCms, you have to set the matomo.url property for this. Since the server will most likely be the same for all websites, it is best to set this property at the /sites/ folder.

Matomo will then provide you with a so-called website ID for each website. This website ID is usually a number, such as 12345.

In OpenCms, you must set this website ID for Matomo in the matomo.id property at the start folder of the relevant website. This has to be repeated for each website that is to be measured individually.

Starting with version 3.13.6, Matomo offers the option of tracking page views without the use of cookies. In this case, Matomo tracking is performed using JavaScript only.

The JavaScript tracking option must be explicitly enabled in OpenCms. To do this, set the matomo.jst property to true. This can be done for all websites simultaneously on the /sites/ folder.

The “Privacy Policy Cookie Switch” feature allows web users to opt out of tracking by JavaScript.

Matomo also offers the option of evaluating the browser's “Do Not Track” header and refraining from tracking page views in this case. This must be set on the Matomo server. If this is set, the matomo.jst property in OpenCms has to be set to the value true: dnt. In the “Privacy Policy Cookie Switch” function, the user is then shown a corresponding message that their page views are not being tracked.

Note: The JavaScript tracking setting with the matomo.jst property only works in conjunction with the matomo.id and matomo.url properties, not with the piwik.id and piwik.url properties.

This feature sets cookies in the “Statistics” group.

This feature uses JavaScript from other servers.

The execution of the Matomo analytics component is controlled by the cookie banner.

If the web user has not consented to statistics cookies, Matomo is still able to track the visit by executing JavaScript. This option of tracking via JavaScript must be activated separately. 

If configured and active, this function is automatically integrated on all pages and is therefore executed when each page is loaded.

When the page is loaded, Matomo sets cookies. These are used to track the web user.

If the web user has rejected statistics cookies but tracking via JavaScript is enabled, no cookies are set for statistical purposes. However, in this case, session cookies or opt-out cookies may be set.

JavaScript files from other servers are loaded for this element. These are executed in the context of the page. This enables comprehensive tracking of the web user's activities on the displayed page.

Matomo can be hosted on its own server. In this case, no data is transferred to external service providers. Alternatively, Matomo can also be purchased from a service provider.

Setting the Piwik PRO properties “piwik.url” and “piwik.id”

Note: In January 2018, the Piwik software was renamed Matomo (blog article on this topic). Only use the configurations described here if you are using Piwik PRO and not Matomo.

To use Piwik PRO, you must specify the URL of the Piwik PRO server you are using. In OpenCms, you must set the piwik.url property for this purpose. Since the server will probably be the same for all websites, it is best to set this property on the /sites/ folder.

Piwik PRO will then provide you with a so-called website ID for each website. This website ID is usually a number, e.g. 12345.

In OpenCms, you must set this website ID for Piwik PRO at the start folder of the respective website in the piwik.id property. This must be repeated for each website that is to be measured individually.  

This feature sets cookies in the “Statistics” group.

This feature uses JavaScript from other servers.

The execution of the Piwik PRO analytics component is controlled by the cookie banner. This function is disabled if the web user has not consented to statistics cookies.

If configured and active, this function is automatically integrated into all pages and is therefore executed when each page is loaded.

When the page is loaded, Piwik PRO sets cookies. These are used to track the web user.

For this element, external JavaScript files are loaded from the Piwik PRO servers. These are executed in the context of the page. This enables comprehensive tracking of the web user's activities on the displayed page.

In addition to classic web statistics, Matomo and Piwik PRO now offer a more modern and advanced analysis option via the Tag Manager. In older Matomo versions, the Tag Manager must first be installed as a plugin, while in newer Matomo versions and in Piwik PRO, the Tag Manager is available by default.

Once Tag Manager is set up, you will receive a Container ID. In Matomo, this is a string of numbers, lowercase and uppercase letters, e.g. “M9AeoyHz”; in Piwik PRO, the container ID has the form of a UUID, e.g. “04868047-4d3d-4ef5-86ef-342005a73086e”.

This container ID is required for configuration in OpenCms:

  • Enter the keyword “container” followed by an underscore ‘_’ and the container ID as the value for the matomo.id (or piwik.id) property, e.g. “container_M9AeoyHz”.
  • If not already present, enter the server URL you are using by setting the URL as the value of the matomo.url (or piwik.url) property.

The keyword “container_” preceding the ID addresses the Tag Manager endpoint of the configured provider.

When switching from conventional tracking to tracking with Tag Manager, the server URL remains the same—only the value of the matomo.id (or piwik.id) property needs to be changed.

Note: With the Matomo or Piwik PRO Tag Manager, other functions (“tags”) such as social media buttons can be integrated in addition to web user statistics. Ultimately, the Tag Manager can insert any HTML and JavaScript into a Mercury website. If functions are integrated that go beyond pure web user statistics, this is not covered by the Mercury cookie banner in terms of data protection law.

Setting the Google tracking ID in the property “google.analytics”

To use Google Analytics, you must first create an account with Google. Detailed instructions on how to do this are available on the Google website, for example.

Google will then provide you with a tracking ID for each website. This tracking ID usually has the format UA-1234567-8.

In OpenCms, you have to set this tracking ID for Google Analytics in the google.analytics property at the start folder of the corresponding website. This must be repeated for each website that is to be measured individually.

This feature sets cookies in the “Statistics” group.

This feature uses JavaScript from other servers.

The execution of the Google Analytics component is controlled by the cookie banner. This function is deactivated if the web user has not consented to statistics cookies.

If configured and active, this function is automatically integrated into all pages and is therefore executed when each page is loaded.

When the page is loaded, Google sets cookies. These are used to track the web user.

External JavaScript files are loaded from Google's servers for this element. These are executed in the context of the page. This enables comprehensive tracking of the web user's activities on the displayed page.