Piwik Destination

Segment makes it easy to send your data to Piwik (and lots of other destinations). Once you've tracked your data through our open source libraries we'll translate and route your data to Piwik in the format they understand. Learn more about how to use Piwik with Segment.

Getting Started

To get started using Piwik via Segment you’ll need your Site ID and Server URL. Both are available in your Piwik snippet.

Page

Our page method triggers a call to Piwik’s trackPageView method.

Identify

Our identify method triggers a call to Piwik’s setUserId method and will send the userId.

Track

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

Events can be sent from the browser, your server, or our mobile SDKs. Here’s a basic track example:

analytics.track('Logged In');

For this example these event attributes are sent to Piwik:

Event CategoryAll
Event ActionLogged In

And another track example, this time with all the available Piwik event parameters:

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

That call will create a Piwik 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.

Custom Variables

Piwik 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.Piwik.customVars dictionary of each call.

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

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 Piwik Goals you can do so by mapping those events in your Segment Source Destinations page under Piwik Settings.

piwik goals settings

Fill in the event on the left and the Goal ID from Piwik on the right. Then every time the event happens we’ll fire Piwik’s trackGoal method.


Supported Sources and Connection Modes

WebMobileServer
📱 Device-based
☁️ Cloud-based

To learn more about about Connection Modes and what dictates which we support, see here.

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.


If you have any questions or see anywhere we can improve our documentation, please let us know or kick off a conversation in the Segment Community!