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?): void
trackEvent(category, action, name?, value?, dimensions?): void
trackEvent(category, action, name?, value?, dimensions?): void
trackEvent(category, action, name?, value?, dimensions?): void
trackEvent(category, action, name?, value?, dimensions?): void
trackEvent(category, action, name?, value?, dimensions?): void
Parameters
category (string, required)
The category of the tracked event.
action (string, required)
The action of the tracked event.
name (string, optional)
The name of the tracked event.
value (float, optional)
The value you want to assign to the tracked event.
dimensions (object, optional)
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.)
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?): void
trackEvent(category, action, name?, value?, dimensions?): void
trackEvent(category, action, name?, value?, dimensions?): void
trackEvent(category, action, name?, value?, dimensions?): void
trackEvent(category, action, name?, value?, dimensions?): void
trackEvent(category, action, name?, value?, dimensions?): void
Notes
- 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 6 days ago