简体   繁体   中英

How to Track Store Locator Search terms in Google Universal Analytics

I am in the process of setting up enhanced Ecommerce for GA and have had a few requests of additional of what else the client would like to see in their reports. Once of which is

"Where can i see a report if the locations that a use types in when they use the store locator"

There is already an internal search functionality thats been set up and is tracking the search terms people are typing when looking for products, but i'm not sure if i would need to set this up as a second search terms report or if it's something different?

The URL of the page is different to the internal search results and is www.domain.com/store-locator#wales|GB|0|0|0

Any insight into this would be really helpful.

Thanks, Roxi

As to me knowledge, you are not able to use bookmarks (#something) in GA for internal site search setup. Only GET and POST parameters are allowed. In your situation I think the best solution is to use GA events to send the data about used location each time the user is using this functionality. You need to include addition ga() function call to track those events. Info about how to set it up you could find here: event tracking . After setting things up, you will see all the info about number and type of called events in Behavior -> Events reports section in GA.

Example code:

<button onlick="var hash_location=window.location.hash;ga('send','event','Locator',has_location)">Click me</button>

With such function new event will be send to GA with Event Category=Locator and Event Action=hash in the url. You have some complicated hash, so most probably you need to extract first some info from this using regular expression. Example to get first item from |-separated list in the hash:

var pattern = new RegExp('[^#|]+');
var hash_location = pattern.exec(window.location.hash)[0];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM