How to create custom dimensions

Learn what custom dimensions are, why they're useful and how to create them.

What is a custom dimension? 

A custom dimension is data about your visitors that you want to assign your visitors. It could be their lead status, membership types or if certain actions they're performed on your website. Or it could be data about their actions like product ratings, levels of stock or the published date of content. The custom dimension data will be shown along your regular view. 

How to create custom dimensions

The analytics settings are placed the sidebar menu, and there you will find both visit dimensions and action dimensions. 

We'll first go through how to create visit dimensions, and then action dimensions.

Visit dimensions

Click "Add visit dimension" and give it a descriptive name.

Next, select the tracker you use below for further instructions: 

Action dimensions

Click "Add action dimension" and give it a descriptive name.

If you want, you can add an extraction. Regex can be used to extract the value for the custom dimension from a page URL or title automatically, instead of setting it manually via a tracking client. Note that if multiple extractions are defined, the first extraction that it matches will be used. 


If you'd rather set the value manually, click on the tracker you use. Note that dimension values set manually take precedence over extractions. 

JavaScript tracker 

Tracking a custom dimension across multiple tracking requests 

To start tracking a custom dimension, you need to set the name and the value (what you want to track). 

extellio_actions.push([
'setCustomDimension',
customDimensionId = 1,
customDimensionValue = 'Lead'
]);

Once a custom dimension has been set, that value will be used for all following tracking requests which will affect the results. The method will not trigger a tracking request, instead the values will be sent along with the next tracking requests. 

For example, if you track a page view the value will be tracked for each following action like a download or clicked outlink etc. 

To avoid this, you can delete the value after a tracking request. 

extellio_actions.push(['deleteCustomDimension', customDimensionId]);

Setting a custom dimension for the initial page view

If you want to track the custom dimension for the first page view, you need to place the method before trackPageView. 

extellio_actions.push([
'setCustomDimension', customDimensionId = 1, customDimensionValue = 'Member'
]);
extellio_actions([
'trackPageView'
]);

// extellio_actions.push(['enableLinkTracking']);
// rest of tracking code

Tracking a Custom Dimension for one specific action only

If you only want to track the custom dimension for a specific action, you can send one or more specific custom dimension values along with that tracking request. The benefit of using this method is that you don't need to delete the value after the tracking request. 

For example, if you want to track a page view you could send 

extellio_actions.push(['trackPageView', pageTitle, {dimension1: 'DimensionValue'}]);

Define the dimension value by passing an object defining one or more properties as the last parameter. 

Specify all parameters as defined in the method. 

The property name for the dimension will be the dimension followed by the ID, for example dimension1. You can set multiple dimension values like this: 

extellio_actions.push([
    'trackPageView', pageTitle,
    {
        dimension1: 'DimensionValue',
      dimension2: 'Test',
      dimension3: 'Value'
    }
]);

Retrieve a value 

You can use this function to retrive the value, note that it only works if the dimension was set during the same page load. 

getCustomDimension(customDimensionId)

PHP tracker 

$tracker->setCustomDimension('1', 'dimensionValue');
It accepts the following parameter(s):
  • $id (int) — id of the custom dimension
  • $value (string) — value for the custom dimension

It returns a $this value.

You can use clearCustomDimensions() to clear all set dimensions and getCustomDimension() to retrive the value of the custom dimension with the given ID. 

HTTP tracker 

To track custom dimensions, you need to send a HTTP request (GET or POST) to your Tracking HTTP API endpoint, for example, https://yourdomain.example/matomo.php with the following query parameters set: 

&dimension1=dimensionValue