To add basic event tracking to an element on the page, add this attribute with the appropriate values you'd like to send, separated by pipes |
.
<button data-track="category|action|opt_label|opt_value|opt_noninteraction">
Basic Tracking
</button>
For every link or form with a data-track
attribute that takes you to a new page (navigates somewhere else), add this attribute with a value of "true". This delays the loading of the new page for a 100ms to help ensure the _utm.gif request has adequate time to go through (for the event to be tracked).
<a href="link" data-track="category|action|opt_label" data-track-delay="true">
Tracking with delayed navigation
</a>
To use alternate tracking for special cases like _trackSocial
, add this attribute with the desired method name as the value. If this attribute is omitted, tracking defaults to _trackEvent
.
<a href="facebook.com" data-track="category|action|opt_label" data-track-method="_trackSocial">
Social Tracking
</a>