setCustomVariableForIndex
Deprecated
This method is no longer recommended. Use the setCustomDimensionForID() method instead.
The setCustomVariableForIndex() method sets a custom variable in the screen (action) or visit (session) scope. The value can be sent to Piwik PRO with a screen view or any other event.
Syntax
[[PiwikTracker sharedInstance] setCustomVariableForIndex:index
name:@"name"
value:@"value"
scope:CustomVariableScopeAction];
Parameters
index (number, required)
The index where the variable is stored.
Note: If includeDefaultCustomVariable = YES is set, you can only use an index greater than 3 because this method automatically tracks some items under the index 1-3. The includeDefaultCustomVariable = YES method is set by default.
name (string, required)
The name of the variable. Valid format: UTF-8. Limited to 200 characters.
value (string, required)
The value of the variable. Valid format: UTF-8. Limited to 200 characters.
scope (string, required)
The scope of the variable. Enum: CustomVariableScopeVisit or CustomVariableScopeAction.
Examples
To set a custom variable in the screen (action) scope and send it with a screen view:
[[PiwikTracker sharedInstance]
setCustomVariableForIndex:1
name:@"Rating"
value:@"5"
scope:CustomVariableScopeAction];
Notes
- The screen (action) scope refers to events like a screen view or file download and holds a captured variable for each event. The value is removed after an event is called.
- The visit (session) scope refers to the entire session and holds the captured custom dimension for the entire session.
Related methods
Updated 2 days ago