How to track user search terms with Google Analytics
-
- Propeller Head
- Posts: 68
- Joined: Fri Aug 22, 2014 12:24 pm
How to track user search terms with Google Analytics
Propeller-heads, I've written a new blog post detailing how you can track and capture what your users are searching for in your HTML outputs, with the help of Google Analytics. With search term tracking, you can better understand what your users are looking for and make improvements to your help system.
Google Analytics is free, so if you have HTML output, there's no reason not to do this!
http://mike.kelley.consulting/blog/how- ... tml-output
If you want to be notified when new blog posts are added to my site, I've developed an RSS feed you can use:
http://mike.kelley.consulting/blog/rss.xml
Happy search tracking!
Google Analytics is free, so if you have HTML output, there's no reason not to do this!
http://mike.kelley.consulting/blog/how- ... tml-output
If you want to be notified when new blog posts are added to my site, I've developed an RSS feed you can use:
http://mike.kelley.consulting/blog/rss.xml
Happy search tracking!
Re: How to track user search terms with Google Analytics
Thanks - looks a really neat solution, I've set it up in our analytics.
That will capture the search terms when you visit a topic from the search results.
Just bear in mind that it won't capture the search term if someone doesn't visit a topic.
So if people search for terms that they can't find in your help, then you won't know about those.
I find it useful to capture those terms too, as they can indicate if things are missing, or alternative terminology.
Just I've used the standard GA code for ages, and it seems to work fine as it is.
That will capture the search terms when you visit a topic from the search results.
Just bear in mind that it won't capture the search term if someone doesn't visit a topic.
So if people search for terms that they can't find in your help, then you won't know about those.
I find it useful to capture those terms too, as they can indicate if things are missing, or alternative terminology.
Why do you need the link to jsapi and what does that do?In order to get GA to work with Flare, you must add a link to Google's jsapi library before your custom GA code.
Just I've used the standard GA code for ages, and it seems to work fine as it is.
-
- Propeller Head
- Posts: 68
- Joined: Fri Aug 22, 2014 12:24 pm
Re: How to track user search terms with Google Analytics
That's a good point. My previous solution was some JavaScript I wrote that transformed Flare's hash-based URL query to a regular URL query that GA could detect, and post it back to GA. If I wanted to capture the scenarios you indicate, that JavaScript would work. I just like this as a cleaner solution and my team hasn't really missed the extra searches yet.Dave Lee wrote:Just bear in mind that it won't capture the search term if someone doesn't visit a topic.
So if people search for terms that they can't find in your help, then you won't know about those.
When I originally set up GA, it gave me a link to the jsapi library, but the link was in a src="//google.com/jsapi" format which made Flare barf all over the build. I didn't know that GA works fine without it now.Dave Lee wrote:Why do you need the link to jsapi and what does that do?In order to get GA to work with Flare, you must add a link to Google's jsapi library before your custom GA code.
Just I've used the standard GA code for ages, and it seems to work fine as it is.
Re: How to track user search terms with Google Analytics
Question - are we required to use HTML5 output in order to make Google Analytics work? The company I work for wants a WebHelp output and they've used G.A. in RoboHelp and they want it to work in Flare without going to HTML 5.
is this possible?
I have the entire google code that I could insert into the master webhelp page - any thoughts or suggestions?
Thanks
Elaine
is this possible?
I have the entire google code that I could insert into the master webhelp page - any thoughts or suggestions?
Thanks
Elaine
Re: How to track user search terms with Google Analytics
No, GA will work in regular WebHelp too.ElaineB wrote:Question - are we required to use HTML5 output in order to make Google Analytics work?
Re: How to track user search terms with Google Analytics
Mike, this post is from a while ago, I know, but I found it useful almost a year later. Thanks!
I've set up Google Analytics on my doc site, but I did notice that I had to remove the link to Google's jsapi library to get the GA tagging to work properly.
Would you be willing to share the JavaScript you developed that transformed Flare's hash-based URL query to a regular URL query that GA could detect and post back to GA?
I'm interested in tracking user search where the user wasn't successful in finding what they were looking for.
I've set up Google Analytics on my doc site, but I did notice that I had to remove the link to Google's jsapi library to get the GA tagging to work properly.
Would you be willing to share the JavaScript you developed that transformed Flare's hash-based URL query to a regular URL query that GA could detect and post back to GA?
I'm interested in tracking user search where the user wasn't successful in finding what they were looking for.
Re: How to track user search terms with Google Analytics
I track searches with no results for my Flare help sites.
I have it set up as follows:
* I create a search results page, which is a topic that contains a search results proxy.
* The search results page first loads the GA script, followed by this script:
* Then I can go into Google Analytics and see these recorded as events, with category - "Search", action - "No results", label - the search term.
I have it set up as follows:
* I create a search results page, which is a topic that contains a search results proxy.
* The search results page first loads the GA script, followed by this script:
Code: Select all
$(document).ready(function(){
/* ----- record search terms with no results ------ */
if($(".total-results").length == 0) {
/* not search results page */
} else {
/* check for any DOM changes in results number */
$(".total-results").on('DOMSubtreeModified', function () {
var totalResults = $(this).text();
/* strip quotes from term string */
var searchTerm = $(".query").text().replace(/\"/g, "");
/* if results number equals zero, send analytics event */
if (totalResults == "0") {
ga('send', 'event', 'Search', 'No results', searchTerm);
}
});
}
});
Re: How to track user search terms with Google Analytics
Thanks for sharing, David.
I also found a way to capture search terms that don't result in users clicking on a page in Google Analytics without adding additional javascript.
I'm using Content Grouping in GA to analyze user behavior on different parts of our doc site, so I set up a Content Grouping with a rule definition for search queries.
The rule is defined like this:
Page contains /Search.htm?q=
When I view Site Content reports using Content Groups, I can see search terms listed in the page name.
For example, a search for "new account" shows up as Search=htm?q=new account in the report.
Thought I'd share in case anyone may find it useful in the future.
I also found a way to capture search terms that don't result in users clicking on a page in Google Analytics without adding additional javascript.
I'm using Content Grouping in GA to analyze user behavior on different parts of our doc site, so I set up a Content Grouping with a rule definition for search queries.
The rule is defined like this:
Page contains /Search.htm?q=
When I view Site Content reports using Content Groups, I can see search terms listed in the page name.
For example, a search for "new account" shows up as Search=htm?q=new account in the report.
Thought I'd share in case anyone may find it useful in the future.
-
- Sr. Propeller Head
- Posts: 189
- Joined: Mon Feb 22, 2016 9:18 am
- Location: Cincinnati, OH
Re: How to track user search terms with Google Analytics
We are testing no results tracking, and found that search filters are causing issues. For example, we might get a notification that a search for "new topic" does not have any results, but the reason it doesn't have results is because the user applied a specific search filter.
Has anyone adapted search term tracking to also track search filters? I've found the code that highlights the active search filter, I just don't know the JS to put that information to good use.
Has anyone adapted search term tracking to also track search filters? I've found the code that highlights the active search filter, I just don't know the JS to put that information to good use.
You do not have the required permissions to view the files attached to this post.
Casey
Re: How to track user search terms with Google Analytics
I know the filter is added as parameter to the URL:
.../SearchResults.htm?q=term&f=filter
So you could capture that, e.g. here the filterTerm variable is set to "None", or set as the filter term if one exists:
(Note - this is a very simple solution that assumes filter is the last parameter in the URL. It might need more a more robust solution if the URL format is likely to change.)
And include that filterTerm information when you send the event to GA:
.../SearchResults.htm?q=term&f=filter
So you could capture that, e.g. here the filterTerm variable is set to "None", or set as the filter term if one exists:
Code: Select all
var filterTerm = "None";
if (window.location.search.indexOf('f=') > -1) {
filterTerm = location.search.split("f=")[1];
}
And include that filterTerm information when you send the event to GA:
Code: Select all
ga('send', 'event', 'Search - No results', filterTerm, searchTerm);
-
- Sr. Propeller Head
- Posts: 189
- Joined: Mon Feb 22, 2016 9:18 am
- Location: Cincinnati, OH
Re: How to track user search terms with Google Analytics
Thank you so much, Dave. We made a minor modification to your code, but this got us pointed in the right direction! I really appreciate your help.
In case anyone is interested, we found that we had to replace "search" with "href" for the URL to be read correctly:
In case anyone is interested, we found that we had to replace "search" with "href" for the URL to be read correctly:
Code: Select all
var filterTerm = "None";
if (window.location.href.indexOf('f=') > -1) {
filterTerm = location.href.split("f=")[1];
}
Casey
-
- Sr. Propeller Head
- Posts: 153
- Joined: Tue May 05, 2009 1:07 pm
Re: How to track user search terms with Google Analytics
Wondering if I should be able to see the Google Analytics code in my output? When I build, it seems to strip out the GA code. Is that possible?
Re: How to track user search terms with Google Analytics
Yes, you should be able to see the GA code in the output.Nina Esile wrote:Wondering if I should be able to see the Google Analytics code in my output? When I build, it seems to strip out the GA code. Is that possible?
It may not be included, depending on how/where you've added the code:
* Anything in the head section of a topic is not included in the output. If you want it in the head, it needs to be in the master page head section.
* Anything in the body section of a topic is included in the output.
-
- Sr. Propeller Head
- Posts: 153
- Joined: Tue May 05, 2009 1:07 pm
Re: How to track user search terms with Google Analytics
That's it, Dave. Thanks. I hadn't put it in the master page. I tried that and it worked.* Anything in the head section of a topic is not included in the output. If you want it in the head, it needs to be in the master page head section.
* Anything in the body section of a topic is included in the output.