setCustomDimensionForID

The setCustomDimensionForID() method sets a value for the custom dimension. The value can be sent to Piwik PRO with a screen view or other event.

Syntax

[[PiwikTracker sharedInstance] setCustomDimensionForID:customDimensionId value:@"customDimensionValue"];

Parameters

customDimensionId (number, required)

The ID of the custom dimension.

customDimensionValue (string, required)

The value of the custom dimension.

Examples

To set a custom dimension with the ID 1 and the value 5 stars and send it with a screen view:

[[PiwikTracker sharedInstance] setCustomDimensionForID:1 value:@"5 stars"];

To set a custom dimension with the ID 2 and the value paid subscriber and send it with an event:

Notes

  • Before setting and sending a custom dimension value, you need to create a session or event custom dimension in Piwik PRO (Menu > Analytics > Settings > Custom dimensions). You can then use the dimension ID to track the value.
  • After a dimension is sent with an event, it is deleted and will not be sent with the next event. So, you have to set it each time you want to send it.