trackCustomEvent

The trackCustomEvent() method records actions performed by users on your mobile app – like button presses, gestures or voice commands.

Syntax

const options = {
  name: 'name',
  path: 'path',
  value: value,
  customDimensions: { dimensionID: 'value', dimensionID: 'value', },
}
await PiwikProSdk.trackCustomEvent(`category`, 'action', options);

Parameters

category (string, required)

The category of the tracked event. You can define event categories based on actions (clicks, gestures, voice commands) or features (play, pause, fast forward).

action (string, required)

The action of the tracked event. Example: A category could be user clicks, an action could be a button click.

options

Custom event options: an object containing five properties.

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 clicked.

value (float, optional)

The value you want to assign to the tracked event. For example, if you’re tracking “Buy” button presses, you can record the number of purchased items or the total cost.

path (string, optional)

The URL path set for this event.

customDimensions

An object that specifies custom dimensions.

visitCustomVariables

An object that specifies visit custom variables.

Examples

To send a custom event when a user clicks a sign-up button on /main/sign-up and assign the value 100 to the event:

const options = {
  name: 'Sign up',
  path: 'example/sign-up',
  value: 100,
  customDimensions: { dimensionID: 'value', dimensionID: 'value', },
}
await PiwikProSdk.trackCustomEvent(`Button`, 'Clicks', options);

Notes