Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

Matomo Destination


Destination Info
  • Accepts Page and Track calls.
  • In Device-mode, refer to it as Piwik in the Integrations object
Connection Modes
Device-modeCloud-mode
Web Web
Mobile Mobile
Server Server

Matomo(link takes you to an external page), formerly Piwik, is the leading open source web analytics platform that gives you valuable insights into your website's visitors, your marketing campaigns and much more, so you can optimize your strategy and online experience of your visitors.

Segment's Matomo destination code is open-source and can be viewed on GitHub:


Getting started

getting-started page anchor
  1. From the Segment web app, click Catalog.
  2. Search for "Matomo" in the Catalog, select it, and choose which of your sources to connect the destination to. Note the source must be sending events using the Segment JavaScript library Analytics.js.
  3. In the destination settings, enter your Site ID. You can find your Site ID in your Matomo snippet.
  4. In the destination settings, enter your Server URL. You can find your Server URL in your snippet. Segment automatically appends /matomo.php to the URL.
  5. When you enable Matomo in your Segment settings, Segment's CDN is updated within 45 minutes. Once that happens, Segment asynchronously loads matomo.js on your page whenever it is loaded. This means you should remove Matomo's snippet from your page.

If you're not familiar with the Segment Specs, take a look to understand what the Page method does. An example call would look like:

analytics.page();

The Page method triggers a call to Matomo's trackPageView method.


If you're not familiar with the Segment Specs, take a look to understand what the Identify method does. An example call would look like:

analytics.identify('97980cfea0068');

The Identify method triggers a call to Matomo's setUserId method and will send the userId to Matomo.


If you're not familiar with the Segment Specs, take a look to understand what the Track method does. An example call would look like:

analytics.track('Logged In');

Segement records a Matomo event whenever you make a track call.

In the example, these event attributes are sent to Matomo:

Event CategoryAll
Event ActionLogged In

See the following Track example, this time with all the available Matomo event parameters:

1
analytics.track('Created Account', {
2
category: 'Account',
3
label: 'Premium',
4
value: 30
5
})

That call creates a Matomo Event with these attributes:

Event CategoryAccount
Event ActionLogged In
Event NamePremium
Event Value30

For Event Value, you can name the event property value or revenue. Segment looks for value first, then fall back to revenue.


Matomo lets you set custom variables(link takes you to an external page) with your pageviews and events. With Segment, you can set page-scoped custom variables with any Track call you make with analytics.js.

Since these custom variables must be mapped to an index you define, which can change from call to call, the only way that Segment can support these custom variables with full flexibility is to allow you to pass your map in the context.Matomo.customVars dictionary of each call.

To take advantage of this feature, your Track calls should look like this:

(information)

Info

The destination's name is still "piwik" in the JSON for these calls.

1
analytics.track('event', {
2
property: 'property'
3
}, { integrations: {
4
Piwik: {
5
customVars: {
6
1: ["<variableName>", "<variableValue>"],
7
2: ['SubscriptionId', '1234'],
8
3: ['PlanName', 'ENTERPRISE']
9
}
10
}
11
}
12
})

Goals

goals page anchor

If you want to flag specific events as Matomo Goals, you can do so by mapping those events in your Segment Source Destinations page under Matomo Settings.

Fill in the event on the left and the Goal ID from Matomo on the right. Then every time the event happens Segment fires Matomo's trackGoal method.


Segment lets you change these destination settings from the Segment app without having to touch any code.

Property nameTypeRequiredDescription
Custom Variable Limitnumber

Optional

If you have manually changed your Matomo custom variable limit, please enter your new value here. The Matomo default is 5.

Default: 5

Goalstext-map

Optional

Matomo only allows for goal ID's, when you track('event') we need to map event to a goal ID, enter event names on the left and goal ID's on the right.


Site IDstring
required

You can find your Site ID in your Matomo snippet.


Server URLstring
required

You can find your Server URL in your snippet, we will append /piwik.php to the URL automatically.