Support > Advanced Topics > How to integrate your store locator with Google or Bing Analytics

How to integrate your store locator with Google or Bing Analytics

In this guide we describe how to integrate your store locator with Google or Bing Analytics. This guide can also be used to integrate your locator with any external script.

The most common use for this sort of integration is so that you can track conversions inside Google Analytics whenever a visitor searches for a location inside your store locator. Whenever a search event occurs inside the locator, the following local function is called if it exists:


So, the following script will call the ga function to send a pageview event whenever a search event takes place in your store locator

 ga('create', 'UA-XXXXX-Y', 'auto');

  function storeLocatorSearchEventHandler(eventData) {
    ga('send', 'pageview');

Additional data about the search event is passed inside the eventData object and this can be used to enhance or provide further detail of the conversion type. Here are the attributes of the eventData object:

  • address: The address that was searched (either the address entered into the input field or the address of the midpoint of the map if the 'My Location' button was used to geolocate the visitor)
  • distance: The distance in kms to the closest location
  • filters: Any filters that were applied
  • map_lat: The latitude of the address
  • map_lng: The longitude of the address
  • nearest_storeid: The StoreID of the closest location
  • nearest_storename: The name of the closest location
  • referrer: The HTTP referrer if available (web page which linked to this page)
  • type: The type of search - either "geolocate" where geolocation (the My Location) button was used or "address" where an address was searched for.
  • uid: Your unique account user ID 
  • url: The URL of the current page