Event Tracking

Other topics

Tracking searches within your site

Insert the following function call within your JavaScript when searching within your website to track how visitors are using your internal search features.

In this example, the Event Action filters is a comma-delimited list of search filter name/value pairs, and the Event Label orderedBy is a string describing the user-determined sort order.

ga('send', 'event', 'Product Search', filters, orderedBy);

These events can then be viewed within Analytics under Behavior > Events:

Event shown by Action

Likewise, the searches can be viewed by Label to see how users are sorting their data: Event shown by Label

Track shopping cart actions

Adding a product to a shopping cart (Label item.name references the name property of the product added):

ga('send', 'event', 'Cart', 'Add', product.name);

This lets you see what people are adding to the shopping cart, even if they never complete the order, allowing more insight into where users are abandoning their session: A list of which products were added to the custom shopping cart

Removing an item from a shopping cart:

ga('send', 'event', 'Shopping', 'Removed', product.name);

Emptying a shopping cart:

ga('send', 'event', 'Cart', 'Emptied', 'empty');

Syntax:

  • ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

Parameters:

Field NameDescription
eventCategoryTypically the object that was interacted with (e.g. 'Video')
eventActionThe type of interaction (e.g. 'play')
eventLabelUseful for categorizing events (e.g. 'Fall Campaign')
eventValueA numeric value associated with the event (e.g. 42)

Contributors

Topic Id: 6521

Example Ids: 22357,22358

This site is not affiliated with any of the contributors.