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:
Likewise, the searches can be viewed by Label to see how users are sorting their data:
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:
Removing an item from a shopping cart:
ga('send', 'event', 'Shopping', 'Removed', product.name);
Emptying a shopping cart:
ga('send', 'event', 'Cart', 'Emptied', 'empty');
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
Field Name | Description |
---|---|
eventCategory | Typically the object that was interacted with (e.g. 'Video') |
eventAction | The type of interaction (e.g. 'play') |
eventLabel | Useful for categorizing events (e.g. 'Fall Campaign') |
eventValue | A numeric value associated with the event (e.g. 42) |