Matomo Destination

Matomo, 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.

This document was last updated on July 18th, 2018. If you notice any gaps, outdated information or simply want to leave some feedback to help us improve our documentation, please let us know!

Getting Started

The first step is to make sure Matomo supports the source type and connection mode you’ve chosen to implement. You can learn more about what dictates the connection modes we support here.

WebMobileServer
📱 Device-mode
☁️ Cloud-mode
  1. From your Segment UI’s Destinations page click on “Add Destination”.
  2. Search for “Matomo” within the Destinations Catalog and confirm the Source you’d like to connect to. Please note the source must be sending events via our Javascript library Analytics.js.
  3. Drop in your Site Id. You can find your Site ID in your Matomo snippet.
  4. Drop in your Server URL. You can find your Server URL in your snippet, we will append /matomo.php to the URL automatically.
    1. 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.

Page

If you haven’t had a chance to review our spec, please take a look to understand what the Page method does. An example call would look like:

analytics.page();

Our Page method triggers a call to Matomo’s trackPageView method.

Identify

If you haven’t had a chance to review our spec, please take a look to understand what the Identify method does. An example call would look like:

analytics.identify('97980cfea0068');

Our Identify method triggers a call to Matomo’s setUserId method and will send the userId to Matomo.

Track

If you haven’t had a chance to review our spec, please take a look to understand what the Track method does. An example call would look like:

analytics.track('Logged In');

We’ll record a Matomo event whenever you make a track call.

For the example above, these event attributes are sent to Matomo:

Event CategoryAll
Event ActionLogged In

Find below another Track example, this time with all the available Matomo event parameters:

analytics.track('Created Account', {
  category: 'Account',
  label: 'Premium',
  value: 30
})

That call will create 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. We’ll look for value first, then fall back to revenue.

Best Pratices

Matomo allows you to set custom variables 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 we 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:

Note The destination’s name is still “piwik” in the JSON for these calls.

analytics.track('event', {
  property: 'property'
}, { integrations: {
  Piwik: {
    customVars: {
      1: ["<variableName>", "<variableValue>"],
      2: ['SubscriptionId', '1234'],
      3: ['PlanName', 'ENTERPRISE']
      }
    }
  }
})

Goals

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 we’ll fire Matomo’s trackGoal method.


Settings

Segment lets you change these destination settings via your Segment dashboard without having to touch any code.

Custom Variable Limit

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

Goals

Piwik 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 ID

You can find your Site ID in your piwik snippet.

Server URL

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

Adding Matomo to the integrations object

To add Matomo to the integrations JSON object (for example, to filter data from a specific source), use one of the 1 valid names for this integration:
  • Piwik


  • Questions? Need help? Contact us!
    Can we improve this doc?
    Email us: docs-feedback@segment.com!