LW IT Solutions logo LW IT Solutions logo LW IT Solutions
« Blog Overview /Digital Analytics/Tutorials / Adding Custom Data to Matomo: Setting Up...
Read this article in other languages:

Adding Custom Data to Matomo: Setting Up Custom Dimensions

Adding Custom Data to Matomo: Setting Up Custom DimensionsAdding Custom Data to Matomo: Setting Up Custom Dimensions

Management Summary

Custom Dimensions add descriptive labels to website statistics in Matomo, such as an article category or membership plan. They make it possible to compare groups that ordinary page counts do not distinguish. The article explains how labels can describe either a whole visit or an individual action. Choosing the right meaning keeps reports useful when circumstances change during a visit. Consistent categories support comparison without needing names, email addresses or other personal identifiers.

Contents
  1. 1. Dimension creation and activation
  2. 2. A value in the relevant request
  3. 3. Matomo Tag Manager configuration
  4. 4. Validation before report comparisons
  5. Fictional example: membership tiers
  6. Questions and answers
  7. Sources

Custom Dimensions add descriptive attributes to Matomo data: for example, a membership tier for a visit or an article category for a page view. A dimension is a label for grouping data, not a metric such as a count or duration. The setup requires a matching dimension ID, the right scope and a value available when the tracking request is sent.

1. Dimension creation and activation

In Administration, Custom Dimensions is available under Websites or Measurables. Setup requires the correct website, a named dimension and activation. The generated numeric ID is the reference used in tracking; the same number on a different website need not describe the same attribute.

  • Visit scope: One value describes the visit. If the value changes during the visit, the last recorded value wins. An upgrade from Standard to Premium therefore does not preserve both stages as separate visit values.
  • Action scope: The value describes an individual page view, event, download or outlink. Different actions can carry different values.
Matomo dimensions: last visit value versus per-action values; values are set before tracking and can persist in the JavaScript tracker.
Matomo dimensions: last visit value versus per-action values; values are set before tracking and can persist in the JavaScript tracker.

2. A value in the relevant request

The following example assumes that ID 1 is an active visit dimension for membership tier. It belongs in an existing, configured Matomo tracker before the page view. The value premium is only an example and must come from the actual application state.

var _paq = window._paq = window._paq || [];
_paq.push(['setCustomDimension', 1, 'premium']);
_paq.push(['trackPageView']);

The example replaces the existing pageview call for this hit; adding a second call would count the page twice.

setCustomDimension does not send a request itself. The configured value accompanies subsequent tracking requests in the same page load until changed or removed with deleteCustomDimension. This also matters for Action dimensions: action scope does not automatically clear the JavaScript tracker value after one action. For a value intended for one action only, Matomo also supports request-specific dimension data. Removing a tracker value does not delete previously collected server data.

3. Matomo Tag Manager configuration

In Matomo Tag Manager, a variable reads the value, for example from a data-layer field. The data layer holds structured application information, such as the current membership tier. In the Matomo Configuration Variable, the dimension ID belongs under Custom Dimensions and the variable supplies the Value. The Matomo tracking tag must use that configuration. Preview should confirm that the value exists when the intended tag fires.

4. Validation before report comparisons

A controlled test checks the site ID, active dimension ID and transmitted dimension1 parameter. It covers at least two values and a missing value. For an Action dimension, a subsequent action reveals accidental carry-over. For a Visit dimension, a value change within one visit tests whether the last value is retained.

Custom Dimensions have dedicated reports and can support segments and, where available, Custom Reports. Availability and metrics depend on scope and the installed product features. An arbitrary secondary dimension cannot be assumed in every standard report. Recent requests may appear in the visit log before aggregated reports finish processing.

Fictional example: membership tiers

The figures below illustrate a report layout only. They are not collected results or evidence that Premium membership causes longer visits. Page views and average visit duration measure different things; the definition of duration and the selected reporting period must be consistent.

Membership Level Page Views Avg. Session Duration
Premium 12,450 04:30
Standard 85,200 01:15

Stable category labels keep reports comparable. Email addresses, names or uncontrolled free text should not be collected merely to distinguish categories. A useful tier value is premium, rather than a personal identifier.

Questions and answers

Can an existing dimension switch between Visit and Action?

The normal configuration does not offer a scope change for an existing dimension. A new dimension with the required scope needs a documented ID and start date. Historical data keeps its original meaning; renaming an old dimension does not convert its scope or backfill past requests.

Does a membership tier always belong at visit scope?

Only when the final tier for the visit answers the reporting question. If actions before and after an upgrade need separate labels, action scope is more suitable. The choice follows the intended analysis, not the attribute name alone.

Lukas Wojcik

Lukas Wojcik

Systems architect and technology enthusiast specializing in scalable tracking solutions, GMP Stack (GA4 & GTM), and robust backend architectures. Advocate for clean code and privacy-first design.

Get in touch

A question or an idea for a web project? Tell me a little about it. This form uses reCAPTCHA and formconfirmed to protect against spam.

Write a comment

Differing figures from other accounts and questions about the setup are welcome here.

The email address is not published. Required fields are marked with an asterisk.

LUKASWOJCIK.COM · NEWSLETTER

Fresh ideas in your inbox

New articles, practical tools and updates from the projects.

Choose topics (optional)
No selection: all topics.

Subscription starts after confirmation by email. · Privacy

Privacy · Newsletter

Email address, language, selected topics and subscription/confirmation dates are stored to deliver the newsletter. Double opt-in is required. Every issue includes an immediate unsubscribe link. Formconfirmed checks the signup for spam. No email open or click tracking.

Read the full privacy policy ↗