Hybrid tracking allows Matomo to collect more detailed analytics data from visitors who give consent, while continuing to track visitors who have not consented under the CNIL consent exemption.

The CNIL consent exemption allows you to track visitors without requiring their consent first. However, it limits the data Matomo can collect, including campaign information, referrer details and User ID. The CNIL restrictions apply to every visitor, regardless if they provide explicit consent.

With Hybrid tracking, you can configure Matomo to treat consenting and non-consenting visitors differently:

  • Visitors who have not given consent: Matomo tracks them under the CNIL consent exemption, with its restrictions in place.
  • Visitors who give consent: Matomo can collect additional data, such as campaign names, full referrer URLs and User ID, while continuing to respect your existing privacy settings.

This means you can continue measuring your audience from the first page view without requiring consent for basic analytics. If you want to collect more detailed data, you still need a consent banner or opt-in mechanism for visitors to give consent.

Hybrid tracking is being released in stages.
Currently, consenting visitors can be tracked with campaign names and keywords, full referrer URLs and User ID. Additional functionality is under development and will be documented as it becomes available.

Before you start

To configure Hybrid tracking, you must have superuser permissions in Matomo and ensure the following requirements are met:

  1. CNIL consent exemption is enabled: Go to Administration admin gear icon > Privacy > Compliance and confirm that the CNIL consent exemption is enforced for your website. Hybrid tracking allows additional tracking when consent is given while maintaining the exemption restrictions for visitors who have not consented.

  2. Cookieless tracking is not enforced: In Privacy > Anonymize data, ensure that the privacy setting, Force tracking without cookies (forceCookielessTracking) is disabled for your website. When this setting is enabled, Matomo does not accept consent for the website, so Hybrid tracking has no effect. Matomo does not display a warning when both cookieless and Hybrid tracking settings are enabled.

  3. Access to your website’s tracking code: You must be able to modify the Matomo tracking code on your website, as described in Step 2 of this guide.

Note: Only superusers can manage the CNIL consent exemption and Hybrid tracking settings. These options are not visible to users with site admin permissions. If you cannot see the settings, contact a Matomo superuser.

How to enable Hybrid tracking for your website

Step 1: Turn Hybrid tracking on for the website

Enable Hybrid tracking to allow Matomo to apply different tracking rules depending on whether a visitor has given consent. Until this setting is enabled, your existing tracking remains unchanged.

  1. Log in to Matomo as a superuser.
  2. Go to Administration admin gear icon > Privacy > Compliance.
  3. Use the selector at the top of the page to choose whether the setting applies to all websites or select a single website.
  4. In the Hybrid Tracking section, toggle on Activate hybrid tracking.
  5. Click Save and enter your password to confirm.

The setting is off by default. To roll it out gradually, turn it on for one website at a time. If you turn it on for all websites, every website uses it.

hybrid tracking off by default

If Hybrid tracking is enabled under All Websites, the setting appears enabled but greyed out when you select Single Website and choose a website. To manage Hybrid tracking for individual websites, first disable it under All Websites, then enable it separately for each website as required.

If you disable Hybrid tracking for a site after previously enabling it, the website returns to the exemption’s treatment straight away. This includes visits that are already open and had been recorded as consented, so the change is not limited to new visits.

Step 2: Declare how your website measures

Update your tracking code to tell Matomo that visitor tracking does not require consent, but the use of cookies and collecting restricted data do. This allows Matomo to track visitors from their first page view without waiting for a consent decision.

Add this to your tracking code, before trackPageView:

_paq.push(['requireConsentForRestrictedData']);
  • Cookies are withheld until consent, as they are with requireCookieConsent(), so this call replaces requireCookieConsent() rather than joining it.
  • Do not combine it with requireConsent(). The two contradict each other: requireConsent() does not track until consent is given, and takes priority if both are called.

Tracking code example

After updating the tracking code, Matomo automatically processes requireConsentForRestrictedData() before other queued tracking commands, regardless of its position in the queue. This ensures that visitors are tracked under the CNIL consent exemption from their first page view, with additional data collected only when they give consent.

<!-- Matomo -->
<script>
   var _paq = window._paq = window._paq || [];

   // Measure every visitor under the CNIL exemption from the first page view.
   // Cookies are withheld until the visitor consents.
   _paq.push(['requireConsentForRestrictedData']);

   _paq.push(['trackPageView']);
   _paq.push(['enableLinkTracking']);
   (function() {
     var u = "//YOUR-MATOMO-DOMAIN/";
     _paq.push(['setTrackerUrl', u + 'matomo.php']);
     _paq.push(['setSiteId', 'YOUR-SITE-ID']);
     var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
     g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
   })();
</script>
<!-- End Matomo Code -->

For a standard Matomo JavaScript installation, place the complete tracking code within the HTML <head> section of your website, ideally just before the closing </head> tag. Make sure the code is included on every page you want to track.

If using Matomo Tag Manager

  1. In Matomo, open your Tag Manager container.
  2. Go to Variables and edit your Matomo Configuration variable.
  3. Tick the option Require consent for data restricted by a compliance policy. You do not need to manually add requireConsentForRestrictedData() to your website’s tracking code. Matomo Tag Manager handles it when this option is enabled.
  4. The consent options are mutually exclusive. When you select one, the other options are hidden.

If you do not see this option, check if Require Consent, Require Cookie Consent or Disable Cookies is set on the same variable and deselect them. Learn more about consent options in the Matomo variable.

Once you have configured the consent setting in Matomo Tag Manager, you also need to notify Matomo when a visitor gives consent through your website’s consent screen. Follow Step 3 below to configure this.

When a visitor gives consent, you need to notify Matomo so it can collect additional analytics data without the CNIL consent exemption’s restrictions. Your existing Matomo privacy settings will still apply.

To do this, configure your consent banner or Consent Management Platform (CMP) to call the appropriate Matomo consent function when a visitor accepts analytics tracking. How you implement this depends on your consent banner or CMP. You may need to add the function to a consent-handling script or configure it to run when the visitor gives consent.

Choose one of the following calls based on how you want Matomo to handle consent:

Option 1: rememberConsentGiven

_paq.push(['rememberConsentGiven']);

rememberConsentGiven() records the consent in an mtm_measurement_consent cookie, so that it is carried to later page views and you do not have to report it again on subsequent page views. requireConsentForRestrictedData() withholds cookies only until consent is given, so this works normally. When using requireConsentForRestrictedData(), cookies are disabled until consent is given, allowing Matomo to store consent once the visitor accepts.
or

Option 2: setConsentGiven

_paq.push(['setConsentGiven']);

setConsentGiven() reports consent for the current page view without storing it for subsequent page views. You must report consent again on every page view.

or

Option 3: For websites using disableCookies() in their JavaScript tracking code

If your website uses disableCookies() in its JavaScript tracking code, use setConsentGiven(false) to report consent while keeping cookies disabled.

_paq.push(['setConsentGiven', false]);

Because no consent cookie is stored, you must report consent on every page view. This configuration is only available when using the JavaScript tracking code, not through the consent options in Matomo Tag Manager.

Server-side tracking and HTTP Tracking API

If you track server-side or through the HTTP Tracking API, send consent=1 on the request. Any other value, or leaving it out, means no consent is being signalled. It does not necessarily mean consent was refused.

Your banner needs two different “no” answers, because they mean different things. One ends the extra data, the other ends measurement.

  • forgetConsentGiven() withdraws consent. Measurement continues under the CNIL exemption, as it did before the visitor consented. Use this for “reject” or “withdraw consent” in your banner.
  • optUserOut() ends measurement entirely, exemption or not. Use this for your opt-out link.
  • forgetUserOptOut() removes the visitor’s opt-out preference, allowing tracking to resume where permitted. It does not grant or signal consent. If consent is required for restricted-data processing, that consent must still be obtained and reported separately.
Consent is recorded against the visit, not the individual request. A visit that has been recorded as consented stays consented until it ends. Withdrawing consent part way through takes full effect from the visitor’s next visit.

Note: setCookieConsentGiven() and rememberCookieConsentGiven() indicate that the visitor accepted cookies, not that they accepted being measured without CNIL exemption restrictions, so they do not unlock the restricted data. The existing mtm_consent cookie is not read as consent to being measured either, because the opt-out form also writes to it.

What this looks like in your reports

Your reports contain both kinds of visit side-by-side. The difference is visible row-by-row.

Campaigns

In Acquisition > Campaigns, visits without consent appear as (UTM parameter discarded) in place of the campaign name and keyword. The visit is still counted and still attributed to a campaign, but you cannot tell which one. Visits with consent show the real campaign name and keyword, allowing individual campaigns to be distinguished as usual.

Referrers

In Acquisition > All Channels and Websites, visits without consent keep the referring website and the channel, but not the rest of the referrer URL or the search keyword, which is what the CNIL exemption requires. Visits with consent carry the full referrer, up to the referrer anonymisation level you configured for the website.

User IDs

In Visitors > User IDs, visits without consent have no User ID at all, so they do not appear in the report and cannot be segmented or linked across visits. For visits with consent, Matomo records the User ID provided through the tracking code, allowing visits associated with the same User ID to be linked.

Consent state cannot be used yet to filter or segment reports. This functionality is planned for a future release.

What to expect from the data

  • If consent is given while the visitor is still on the page they arrived on, the same visit continues and is updated with the campaign and referrer detail from that arrival. This applies however the consent is reported, including by an event or a ping sent directly from the banner.
  • If consent is given after the visitor has moved on to another page, a new visit starts from the next page view. The earlier browsing stays as it was measured, so you see two visits for that visitor.
  • That new visit carries no campaign or referrer because the acquisition information was on the arrival page and no longer available. The visitor’s consented visit is counted as a direct entry.
  • Requests such as pings, events, downloads, outlinks and manual goal conversions cannot start a new visit when consent is given. Once the visitor has moved on, consent reported by one of these applies from their next page view.
  • Nothing is reprocessed. Data discarded before consent such as UTM parameters, cannot be recovered afterwards.

Troubleshooting

If you enabled Hybrid tracking and nothing changed in your reports, check the following in sequential order:

  1. The CNIL consent exemption is enforced for the website, in Administration admin gear icon > Privacy > Compliance.
  2. The Hybrid tracking setting is on for that website in Privacy > Compliance settings.
  3. forceCookielessTracking is not enabled for the website.
  4. Your tracking code calls requireConsentForRestrictedData(), and calls setConsentGiven() or rememberConsentGiven() when the visitor accepts.
  5. Check if anything is blocking matomo.js in the browser, such as an ad blocker or a content blocker.
  6. If campaigns are specifically unchanged but referrers and User ID behave as described, check whether the Marketing Campaigns Reporting plugin is installed and updated (Matomo On-Premise).
Previous FAQ: Configure Matomo Analytics to comply with CNIL consent exemption