---
title: Matomo Tag Manager Setup guide
slug: experience/matomo-tag-manager-setup-guide
docTags: 
createdAt: 2025-03-07T14:04:47.832Z
---

# Description

The prerequisite for successful tracking with the Matomo Tag Manager is that all desired action events, view events and attributes are configured in the "tracking\_config.json". You can find out how to do this in general [here](docId\:SxKxO_OEPT7crFZZOB9Nw).&#x20;

Based on this configuration, PXP sends the corresponding data to Matomo Tag Manager using defined names for triggers and variables.

The configuration must be set up accordingly on Matomo's side. The full PXP support results in the following example structure which shows the full setup to support action-events, view-events and attributes.

**Complete structure used by this example&#x20;**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-6_QxK4FZiBQdUG8LdkxLc-20250514-114505.png)

:::ExpandableHeading
**Matomo Tag Manager structure in detail**

**Tags**

To connect PXP with Matomo Tag Manager, these tags are required based on this example:

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-dUk3ksaf0tdD-NYYhE7Gy-20250514-122520.png)

**Trigger**

To connect PXP with Matomo Tag Manager, these triggers are required based on this example:

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-YG5bMVwv0px400qn8oRZI-20250514-122557.png)

**Variables**

To connect PXP with Matomo Tag Manager these variables are required based on this example:

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-wva_7Z2yS-9FJIj6ESIkQ-20250514-122649.png)
:::

# Events and Attributes

## Action events

### PXP

It starts with an action event configuration. The event "**ISSUE\_OPENED**" is used for the following example. Depending on whether parameters are to be used or not, the configuration differs as follows:

:::CodeblockTabs
Action event

```json
"ISSUE_OPENED": {
  "templates": {
    "category": "content",
    "action": "issue_opened",
    "name": "{{ISSUE_NAME}}",
    "value": 1
  }
}
```

Action event with parameters

```json
"ISSUE_OPENED": {
  "templates": {
    "trigger": "purple.issue_opened",
    "category": "content",
    "action": "issue_opened",
    "name": "{{ISSUE_NAME}}",
    "value": 1    
  },
  "parameters": {
    "3": "{{ISSUE_NAME}}"
  }
}
```
:::

**Reduced code from PXP&#x20;**

PXP web client pushes&#x20;

- an "event" which is configured as "**Trigger**" and
- data which is configured as "**Variable (Data-Layer)**"&#x20;

to Matomo Tag Manager.

The following source code shows a simplified representation of how PXP calls the Matomo Tag Manager API:

:::CodeblockTabs
PXP code for API call

```javascript
// code for action events
const eventData = {
  'event': 'purple.action_event',  // trigger
  'purple': {
    'action_event_action': ... ,   // variable
    'action_event_category': ... , // variable
    'action_event_name': ... ,     // variable
    'action_event_value': ...      // variable
  }
};

window._mtm.push(eventData);
```

PXP code for API call with parameters

```javascript
// code for action events with parameters
const eventData = {
  'event': event.templates?.trigger ?? 'purple.action_event',  // trigger
  'purple': {
    'action_event_action': ... ,   // variable
    'action_event_category': ... , // variable
    'action_event_name': ... ,     // variable
    'action_event_value': ... ,    // variable
    'parameters': { ... } // all configured parameters
  }
};

window._mtm.push(eventData);
```
:::

### Configuration in Matomo Tag Manager

:::::WorkflowBlock
::::WorkflowBlockItem
**Create required "Variables (Data-Layer)" to receive data**

The variable names defined by Purple are as follows:&#x20;

:::BlockQuote
<font color="#2166ae">purple.action_event_category
purple.action_event_action
purple.action_event_name
purple.action_event_value</font>
:::

:::ExpandableHeading
**Matomo Tag Manager example**

**Variable to receive category**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-nzsuc8Vyn-Sn6nssK7vKA-20250514-133604.png)

**Variable to receive action**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-BZKQP2Ol2TDkYdWGT2obi-20250514-133617.png)

**Variable to receive name**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-WfB6PHuDzv3Vjips5lGQc-20250514-133627.png)

**Variable to receive value**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-GcPVkxj-m8dNvlqF87kcW-20250514-133637.png)
:::
::::

::::WorkflowBlockItem
**Create the required “Trigger” for PXP to push to.**

The trigger name defined by Purple is as follows:&#x20;

:::BlockQuote
<font color="#2166ae">purple.action_event</font>
:::

:::ExpandableHeading
**Matomo Tag Manager example**

**Trigger for Action-Event**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-AZp6pasX13Vmg7eAcS8XG-20250514-134223.png)
:::
::::

::::WorkflowBlockItem
**Create a “Tag” that will run when the trigger fires**

Create a tag which creates an action event using the variables from **Step 1&#x20;**&#x61;nd assign the trigger from **Step 2** to define when this tag executes.

:::ExpandableHeading
**Matomo Tag Manager example**

**Tag (Name)**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-MfD72FBdN4SfE_QKtRAjJ-20250514-135131.png)

**Tag (Create event)**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-1Syf3prjlssaXc8_pHMZ7-20250514-135144.png)

**Tag (Use trigger)**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-bL1wjY3P6VEcpc__DGuN7-20250514-135156.png)
:::
::::
:::::

### Summary

Finally, this is how it works together:

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-dYf5pUyMSPhqwbp8MMwMQ-20250514-195132.png)

## View events

### PXP

It starts with a view event configuration. The event "**STOREFRONT\_SEARCH**" is used for the following example.

:::CodeblockTabs
View event

```json
"STOREFRONT_SEARCH": {
  "templates": {
    "name": "{{VIEW}}",
    "title": "Cool search"
  }
}
```

View event with parameters

```json
"STOREFRONT_SEARCH": {
  "templates": {
    "name": "{{VIEW}}",
    "title": "Cool search"
  }, 
  "parameters": {
    "8": "view parameter example: {{FOO}}"
  }
}
```
:::

**Reduced code from PXP&#x20;**

PXP web client pushes&#x20;

- an "event" which is configured as "**Trigger**" and
- data which is configured as "**Variable (Data-Layer)**"&#x20;

to Matomo Tag Manager.

The following source code shows a simplified representation of how PXP calls the Matomo Tag Manager API:

:::CodeblockTabs
PXP code for API call

```javascript
// code for view events
const eventData = {
  'event': 'purple.view_event', // trigger
  'purple': {
    'view_event_name': ... , // variable
    'view_event_title': ...  // variable
  }
};

window._mtm.push(eventData);
```

PXP code for API call with parameters

```javascript
// code for view events
const eventData = {
  'event': view.templates?.trigger ?? 'purple.view_event', // trigger
  'purple': {
    'view_event_name': ... ,  // variable
    'view_event_title': ... , // variable
    'parameters': { ... }     // all configured parameters
  }
};

window._mtm.push(eventData);
```
:::

### Configuration in Matomo Tag Manager

:::::WorkflowBlock
::::WorkflowBlockItem
**Create required "Variables (Data-Layer)" to receive data**

The variable names defined by Purple are as follows:&#x20;

:::BlockQuote
<font color="#2166ae"></font>
:::

:::ExpandableHeading
**Matomo Tag Manager example**

**Variable to receive view title**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-QagbPRYis4ckkXdPvwgAD-20250514-141454.png)

**Variable to receive view name**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-lxK42Z5erJBcU-IqC-E5C-20250514-141512.png)
:::
::::

::::WorkflowBlockItem
**Create the required “Trigger” for PXP to push to.**

The trigger name defined by Purple is as follows:&#x20;

:::BlockQuote
<font color="#2166ae"></font>
:::

:::ExpandableHeading
**Matomo Tag Manager example**

**Trigger for View-Event**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-svWrKMlYsth1BOyLuN15u-20250514-190305.png)
:::
::::

::::WorkflowBlockItem
**Create a “Tag” that will run when the trigger fires**

Create a tag which creates an view event using the variables from **Step 1&#x20;**&#x61;nd assign the trigger from **Step 2** to define when this tag executes.

:::ExpandableHeading
**Matomo Tag Manager example**

**Tag (Name)**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-Uje_bObmEzOjRdhjKWWaj-20250514-142604.png)

**Tag (Create event)**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-X4l_yyEv3PVvmY09QcNY_-20250514-142616.png)

**Tag (Use trigger)**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-WNoSlVJa4JXZGCqmzR7bJ-20250514-142628.png)
:::
::::
:::::

### Summary

Finally, this is how it works together:

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-plGAWfoM2hTKHgwRalfH3-20250514-195209.png)

## Attributes

### PXP

It starts with an attribute configuration. The attribute "**HAS\_BOOKMARKS**" is used for the following example.

:::CodeblockTabs
Attribute

```json
"HAS_BOOKMARKS": {
  "templates": {
    "id": "1"
  }
}
```
:::

**Reduced code from PXP&#x20;**

PXP web client pushes data which is configured as "**Variable (Data-Layer)**" to Matomo.

The following source code shows a simplified representation of how PXP calls the Matomo Tag Manager API:

:::CodeblockTabs
PXP code for API call

```javascript
// code for custom dimensions
const index = ... // value is configured in tracking_config.json
const dataLayerName = `purple.custom_dimension_${index}`;
const customDimensionData = {
    [`${dataLayerName}`]: ... // variable
};
window._mtm.push(customDimensionData);
```
:::

### Configuration in Matomo Tag Manager

:::::WorkflowBlock
::::WorkflowBlockItem
**Create custom visit dimensions**

Add your desired custom visit dimensions.

:::ExpandableHeading
**Matomo Tag Manager example**

**Custom visit dimensions**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-hH7Nm2jgMS4K_DgIpTRsn-20250514-143250.png)
:::
::::

::::WorkflowBlockItem
**Create required "Variables (Data-Layer)" to receive data**

The variable names defined by Purple are as follows:&#x20;

:::BlockQuote
<font color="#2166ae">purple.custom_dimension_1
...
purple.custom_dimension_n</font>
:::

Where "n" is an element of the integer positive numbers.

:::ExpandableHeading
**Matomo Tag Manager example**

**Custom dimension 1 used by "hasBookmarks"**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-rL1fSZyZ3KrCGjwTSyAvB-20250514-143619.png)

**Custom dimension 2 used by "userId"**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-H_D91I7E4O2IKCNKAdm4f-20250514-143632.png)
:::
::::

::::WorkflowBlockItem
**Map custom visit dimensions to Matomo site configuration**

Custom visit dimensions are mapped within the corresponding Matomo site configuration.

:::ExpandableHeading
**Matomo Tag Manager example**

**Matomo site configuration**

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-CbIOm1UBeu4qPs1ni1VPY-20250514-143739.png)
:::
::::
:::::

### Summary

Finally, this is how it works together:

![](https://api.archbee.com/api/optimize/dEL_muXz6FtCnn5OQPTZk-AWtEqP6fvN6Pr4CYaVwFr-20250514-195232.png)

