21 Jun How to track internal site search using Google Tag Manager
I hope you all loved Search Leeds 2017. I had a enjoyable time, too. One speak particularly stood out, Stephen Kenwright’s How to be Amazon (and beat Google at Search).
I’d like to thank @stekenwright for saying I’ve written a weblog publish on monitoring site search by way of GTM… I assume I would like to end that one.
— Emma Barnes (@ejbarnes89) June 15, 2017
Guess I would like to get cracking.
To be honest to him, I’ve written a number of weblog posts about this matter…
How to double conversion by using Site Search
How to robotically track occasions with Google Tag Manager
The time I did an investigation as to why everybody searches for “Stardoll” on the B3 site”
How to extract site search phrases from subfolders in Google Analytics
So, he’s not unsuitable, I’ve kind of accomplished this already. Just not as one piece.
Forget about GTM for a minute, let’s give attention to Google Analytics
By default, Google Analytics doesn’t track any internal site search for you, that means you could have to inform it “please can you tell me what keywords people type into my search bar”. This is how to track internal site search in Google Analytics:
- Go to Admin
- Go to View Settings
- Go to Site Search Setting
- Tick Site Search Tracking>On
- Add your question parameter
- Optional: Add classes in case your site search makes use of classes
PROTIP: Create a Lowercase Filter for Search Term, it implies that individuals trying to find “SEO” and
To view the internal site search report it’s in Behaviour>Site Search.
And you’ll be able to see all kinds of delights and wonders:
Percentage of people that use site search in your site
Tracking “No Results” with Google Tag Manager
By default, you don’t get to see whether or not the searches returned any outcomes. Tracking searches with “no results” is a extremely great way to generate concepts for content material, amongst different issues.
Every web site’s site search is configured in another way, so this rationalization is for Branded3 – hopefully you need to use the identical strategies to your personal web site. If you’d like further assist, please contact us.
Search your web site for a question you recognize will return no outcomes
If you’ll be able to’t consider a phrase, simply mash your keyboard and hit enter.
Take notice of the message that shows
In the above, you’ll be able to see that “No Results found” shows. In Google Analytics, I would like to see the quantity of pages the place this message fires. Inspect the ingredient to discover the ingredient ID.
In this case, it’s #search-results, which funnily sufficient is our motto (or shut sufficient).
Create a Variable in Google Tag Manager to extract the ingredient
In GTM, go to Variables>User-Defined Variables>New to create a brand new variable.
Create a Dom Element variable with the Selection Method CSS Selector, and enter your selector identify. I’ve used #search-results on this case.
Create a lookup desk variable to type between “No Results” and “Results”
Create one other new variable, this time selecting Lookup Table. Give it the Input Variable that you just simply created (I known as it “Search Result”). Here, I’m in a position to create a rule that claims “if the CSS Selector #search-results says “No results found”, name this “No Results”, and if it doesn’t say that, name it “Results””. I do that by giving it one lookup worth (match No outcomes discovered to -> No outcomes) and a default worth of “Results”. Save your question
Bonus spherical – Create a variable to track the key phrase used
You don’t have to do that, however it should add worth to your report. I created a variable to extract the search question from the URL. You want to create a URL variable with the Query part sort. Add your Query Key (which must be the identical because the Query Parameter from Google Analytics). Save your question.
Create a set off to hearth on search outcomes pages
Go to Triggers>New to create a brand new set off. You want to select a Page View – Dom Ready set off. Choose Some DOM Ready Events. Create a rule for “url contains ”. In my case, that is any web page together with /?s=.
Create an occasion tag to hearth search outcomes as an occasion to Google Analytics
Go to Tags>New to create a brand new tag. You want to select a Universal Analytics tag (for those who’ve not migrated to Universal Analytics… please do, I wrote a information). You want to select Track Type Event. I’ve given the occasions the Category: Search Used, the Action: (that is the lookup desk we created earlier) and Label: (the key phrase extractor variable). Set Non-Interaction Hit to True and configure your Google Analytics as you usually would.
Set the Trigger to the Search outcomes set off that we simply created and save the tag.
PROTIP: Use the GTM Debugger to see if this works, and amend as required! Every web site will likely be totally different.
Once examined, push the tag dwell.
Analyse your outcomes using the occasion report
To see your new occasions, go to the Google Analytics report known as Behaviour>Events>Top Events and search for the “Search Used” occasion class (or no matter you named it).
Click it and you may see what searches had outcomes or not:
You can then click on into Results or No Results to analyse which key phrases got here again with or with out outcomes.
And there you could have it! Please get pleasure from your new information!