sendEvent
The sendEvent() method records actions performed by users on your mobile app - like button presses, gestures or voice commands.
Syntax
PiwikTracker.sharedInstance()?.sendEvent(
category: "category",
action: "action",
name: "name",
value: value,
path: "path"
)[[PiwikTracker sharedInstance]
sendEventWithCategory:@"category"
action:@"action"
name:@"name"
value:@(value)
path:@"path"];Parameters
- category
string, required- The category of the tracked event. You can define event categories based on actions (taps, gestures, voice commands) or features (play, pause, fast forward). - action
string, required- The action of the tracked event. Example: A category could be user interactions, an action could be a button tap. - name
string, optional- The name of the tracked event. For example, if you have multiple button controls on the screen, you can use the name to record the specific ID of the button that was tapped. - value
NSNumber, optional- Numeric value for the event. - path
string, optional- Path segment for this event (without a leading slash). When set, the SDK sets the URL tohttp://{appName}/{path}. When omitted, the SDK uses the same generated page URL as for other tracking calls.
Examples
To send a custom event when a user taps on a signup button on the main/signup flow and assign the value 100 to the event:
PiwikTracker.sharedInstance()?.sendEvent(
category: "Clicks",
action: "Button",
name: "Sign up",
value: 100,
path: "main/signup"
)[[PiwikTracker sharedInstance] sendEventWithCategory:@"Clicks"
action:@"Button"
name:@"Sign up"
value:@100
path:@"main/signup"];Notes
- For more on custom events, see this article.
Updated 15 days ago