Matomo can be configured to track based on cookie consent or tracking consent. Implementing a consent manager simplifies consent collection and adjusts tracking behaviour automatically. With consent configured, you can create consent-based segments to analyse how consent affects data completeness, understand differences in visitor behaviour, and measure the impact on key metrics such as conversions or traffic sources.

For example, you may want to compare metrics like conversions or acquisition channels between visitors who accepted cookies and those who declined.

Note: Your implementation should align with the privacy regulations that apply to your organisation, such as the GDPR or other regional laws.

Option 1: Segment using the built-in Profilable condition

Matomo includes a built-in segment condition called Profilable, which lets you filter reports based on whether cookies were used during a visit. This is a simple way to separate visits from users who gave cookie consent versus those who did not.

To view reports for visitors who gave consent, create a custom segment with the following definition:

  • Select Profilable from the drop-down list and set the condition to Is and choose the value 1, e.g., Profilable Is 1. This indicates Matomo tracking cookies were used.
    Matomo Profilable custom segment

To view reports for visitors who declined consent, create a custom segment with the following definition:

  • Select Profilable from the drop-down list and set the condition to Is and choose the value 0, e.g., Profilable Is 0. This indicates no Matomo tracking cookies were used.

This distinction helps you compare fully tracked visits with cookieless ones, evaluate how consent impacts report completeness, or measure the effectiveness of your consent banner.

Note: The Profilable condition is available in Matomo version 4 and above.

Option 2: Segment using a Custom Dimension

You can use a Custom Dimension in Matomo to track whether a visitor has given cookie consent. This lets you segment your reports based on consent status, which is another useful way to analyse cookieless traffic or filter out non-consenting visitors.

You can define your own values or detection method depending on how your consent management platform (CMP) sets the cookie. Some teams use simpler values like yes / no, or store them in session variables, custom scripts, or different cookies altogether.

The following example uses a consent manager cookie called cmp_authorized_vendors, which has a default value of %2C%2C (no consent given). However, when the visitor grants consent, this value changes to %2Cmatomo%2CMatomo%2C. You can adapt this method to suit your specific CMP implementation.

Create the Custom Dimension

  1. Go to Matomo settings Settings Cog Icon> Measurables > Custom Dimensions.
  2. Create a new Visit Custom Dimension and provide a user-friendly name, e.g., Cookies used or Cookies not used.
  3. Set the dimension to Active and click Create.
  4. Note the ID of the custom dimension you created (e.g. ID 7).

You can now configure the Custom Dimension either by adding it to the Matomo tracking code or by setting it up in Matomo Tag Manager, depending on how tracking is implemented on your site.

Configure the Matomo tracking code

If you are not using Matomo Tag Manager, you can assign the consent status to a Custom Dimension directly in your tracking code.

  1. Inspect the cookie using your browser’s developer tools to confirm the values.
  2. Add JavaScript code to read the value of the consent cookie set by your consent manager. For example:
<script type="text/javascript">
  var _paq = window._paq = window._paq || [];

  // Get consent cookie value
  function getCookieValue(name) {
    const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
    return match ? decodeURIComponent(match[2]) : null;
  }

  var consentValue = getCookieValue('cmp_authorized_vendors');

  // Set Custom Dimension (Visit scope, ID = 7 in this example)
  if (consentValue) {
    _paq.push(['setCustomDimension', 7, consentValue]);
  }

  // Standard Matomo tracking
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//your-matomo-domain.example.com/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    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>

This setup sends the visitor’s consent status as a Custom Dimension with each page view. You can then use it to build consent-based segments in Matomo. Learn more about how to track a custom dimension.

Configure Matomo Tag Manager

If using Matomo Tag Manager, create a variable to capture the consent status from your consent manager and pass it to the Custom Dimension. There is no need to modify the tracking code directly.

Create a new Variable

  1. Open your Tag Manager container.
  2. Go to Variables and click Create New Variable.
  3. Choose First Party Cookie as the type.
  4. Enter the name of the consent cookie used by your consent management platform (CMP). This example uses a cookie called cmp_authorized_vendors.
    mtm first party cookie variable
  5. Inspect the cookie using your browser’s developer tools to confirm the values.

Assign the Cookie Value to the Custom Dimension

  1. In Tag Manager Variables, open the Matomo Configuration Variable.
  2. Scroll to the Custom Dimensions section.
  3. Choose the Custom Dimension ID you created earlier, e.g., 7.
  4. In the Value field, assign the newly-created First Party Cookie variable.
    mtm config custom dimensions
  5. Use Tag Manager’s Preview mode to test the setup before publishing the container to your live environment.

This will send the consent status to Matomo as a Custom Dimension for each visitor.

In the last step, you can now create a new consent-based segment.

The example uses the consent manager cookie called cmp_authorized_vendors. The default value is %2C%2C (no consent given) and the value changes to %2Cmatomo%2CMatomo%2C when consent granted.

To view reports for visitors who gave consent, create a custom segment with the following definition:

  • Choose the new Visit Custom Dimension created earlier, e.g., Cookies used.
  • Set the condition to Contains matomo.
    matomo consent based segment custom

To view reports for visitors who declined consent, create a custom segment with the following definition:

  • Choose the new Visit Custom Dimension created earlier, e.g., Cookies not used.
  • Set the condition to Does not contain matomo.

By combining consent configuration with segmentation, you can gain a clearer view of how privacy choices influence your analytics.