trackEvent
The trackEvent() method records actions that visitors perform on your site – like newsletter signups, button clicks, menu item clicks.
Syntax
trackEvent(category, action, name, value, dimensions)trackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidParameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| category | string | The category of the tracked event. | Yes |
| action | string | The action of the tracked event. | Yes |
| name | string | The name of the tracked event. | No |
| value | float | The value you want to assign to the tracked event. | No |
| dimensions | object | A list of custom dimensions you want to pass with this event. Format for keys: dimensionX where X is the dimension ID. Format for values: percent-encoded (Use the encodeURIComponent() method to encode strings.) | No |
Examples
To send a custom event when a visitor clicks on a signup button:
_paq.push(["trackEvent", "Button", "Sign up"]);trackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidtrackEvent(category, action, name?, value?, dimensions?): voidNotes
- Design and document the framework for naming categories and actions on your site or app. It'll make your reporting clear and easy to understand.
Updated 15 days ago