A common scenario is that you may want to track Store Locator Search events as part of your Google Adwords or other Conversion and goal tracking process using Google Tag Manager. For example, whenever a visitor searches for a location inside your store locator 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).
Getting your Goal Conversion Codes from Google Adwords
Before you get started, you'll need to get the conversion codes for the conversion action which you want to track. Here's the process:
1. In Adwords select Tools -> Conversions
2. Click on the Conversion Action you would like to link
3. Under Tag Setup scroll down select 'Use Google Tag Manager'
4. Your Conversion ID and Conversion Label are shown there (see example below):
Google Tag Manager Installation
1. First, create a new tag.
2. Choose 'Custom HTML' as the type.
3. Paste the following into the HTML field with the Conversion ID and Conversion Label values taken from your Google Adwords Conversion tracking console:
4. You'll want to use a firing trigger of type 'Page View'.
5. Now publish the tag to the page on your website where your store locator is hosted (or to the entire site, either is fine). Search events in your locator should be tracked as Conversions.
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