Skip to main content
All CollectionsFrequently Asked Questions
How do I track an event in Google Analytics?
How do I track an event in Google Analytics?
Updated over 9 months ago

Integrating Google Analytics event tracking with your StoreRocket store locator is a straightforward process. This functionality allows you to gain insights into how visitors interact with your store locator, such as tracking each time a user performs a search. Follow the steps below to set up event tracking.

Step 1: Embed Your StoreRocket Store Locator

First, ensure your StoreRocket store locator is embedded on your website. Here's the basic code snippet you'll need to include in your site's HTML. Replace "XXXXXXXX" with your actual StoreRocket account ID.

<div class="storerocket-store-locator"></div>

<script src="//cdn.storerocket.io/widget.js"></script>
<script>
StoreRocket.init({
selector: ".storerocket-store-locator",
account: "XXXXXXXX" // <-- REPLACE THIS WITH YOUR ACCOUNT ID
});
</script>

Step 2: Set Up Event Tracking

To track search events in Google Analytics, add the following JavaScript code snippet to your website. This code listens for the storerocket-storelocator-search event, which is triggered every time a search is performed using the StoreRocket store locator.

<script>
document.addEventListener('storerocket-storelocator-search', function (event) {
if (window.ga) {
ga('send', 'event', 'storelocator', 'search', event.detail.query);
}
});
</script>

Inside this event listener, you can customize the tracking logic as needed. The example provided sends an event to Google Analytics with the event category set to "storelocator", the event action set to "search", and the event label set to the user's search query.

Customizing Your Event Tracking

This setup provides a basic example of how to track store locator searches. You can further customize your event tracking to include additional details, such as the number of results returned or the user's location.

Conclusion

By integrating Google Analytics event tracking with your StoreRocket store locator, you can gain valuable insights into user behavior and improve the overall effectiveness of your locator. Remember to replace the placeholder values with your actual account information and adjust the tracking logic to suit your specific needs.

If you have any questions or need further assistance, feel free to reach out to our support team.

Did this answer your question?