问题
I have an eCommerce site built on ASPX and search feature doesn't use Query Parameter(?q=keyword). It render a search using a path. If you example search for "Pant", you get /Search/Pants.aspx. But google require to have a query parameter in order to count the number of keywords searched.
So my solution to this was having the following jQuery code inserted in my Search.aspx page. The code fire up a URL with a query parameter to GA including the keyword that was searched for. As you can see I'm using <%= this.keywords %> that eCommerce software use to generate the breadcrumb in the search result page.
The problem with this is when users navigate to page 2,3,4.. through the search results, the jQuery code still fire up to GA the same keywords for being searched when it's not. So the keywords count gets inflated in my GA reports.
Could you please help setup something that will count the search only one time. This is the URL generated when someone go to page 2, /Search/Keywords.aspx/2 and so on. Thanks
<ul class="breadcrumbs">
<li>SEARCH RESULTS FOR "<%= this.keywords %>"</li>
</ul>
<!-- Site Search Tracking Script -->
<script>
$(document).ready(function(){
_gaq.push(['_trackPageview', '/search?q=<%= this.keywords %>']);
});
</script>
回答1:
LyesD,
first of all -- you will endup with inflated pageviews as well (I assume you track a regular pageview and then call the pageview for site-search tracking). Keep that in mind as well.
There is a number of ways going around this limitation, easy and complicated ones. For start, I would suggest event tracking just to give you and idea of how much of importance the site-search actually is. Simply replace '_trackPageview' with '_trackEvent', something like (see documentation for details):
_trackEvent('site-search', 'referrer', 'keyword', undefined, true)
Replace the second parameter (referrer) with dynamically populated document.referrer (so that you can see where the search originated) and third parameter (keyword) with the actual keyword used. Always double check that you are passing STRINGS.
Undefined value for forth parameter is there just because of the reason for using the last parameter, which should in this case be always TRUE . The reason for that is the event is then recognized as non-interaction (which won't skew bounce-rate).
This is not standard implementation, but at least you won't get inflated pageviews numbers and should be quite easy&fast to do. If you later find out that site-search is quite important for your visitors, you could spend more time and resourced to developing the proper way so that you can use all the features of Site Search Reports.
回答2:
Extracting site search queries from path-based URL structures (vs parameter-based) can now be done using Google Analytics filters: http://www.lunametrics.com/blog/2013/07/01/google-analytics-site-search-seo-friendly-urls/
来源:https://stackoverflow.com/questions/19687326/google-analytics-site-search-without-query-parameter-in-url-setup-jquery