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

ParameterTypeDescriptionRequired
categorystringThe category of the tracked event.Yes
actionstringThe action of the tracked event.Yes
namestringThe name of the tracked event.No
valuefloatThe value you want to assign to the tracked event.No
dimensionsobjectA 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?): 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.