How to track Google Adwords Conversions and Goals in your store locator software
A common scenario is that you may want to track Store Locator Search events as a Conversion or Goal in Google Adwords or Google Analytics. For example, whenever a visitor searches for a location inside your store locator software you could record this as a goal inside Google Adwords.
Each time a Search is conducted inside your store locator, the following function is called by the locator if it exists:
A search event is recorded in each of the following scenarios:
- The 'My Location' button is pressed by the visitor.
- The visitor is automatically geolocated (if the Customer Geolocation setting is set to 'Automatically locate user' on your Settings page).
- The visitor searches for an address in the address search field
- The visitor searches for a location using the location search field (if this is enabled).
To enable conversion tracking, you'll first need to add the standard Event snippet for the Click event type from your Google Adwords console to the web page:
Once you've done this, the following sample script will record a Google Adwords conversion each time a search event takes place in your store locator. You'll need to update the text "ADD_YOUR_PAGE_URL_HERE" with the URL of the page on which the script is hosted:
For advanced usage, 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