12

In google analytics, you can track site searches by setting the query parameter. EE does not have search result URLs with a query parameter in them though i.e. search result URLs look like http://mysite.com/search/270ab420bad324607c6286bf28767910/ instead of http://mysite.com/search?q=keyword

So is there an easy way to track site searches using the native EE search module in google analytics - either natively (ideally) or using an add-on? I want to keep using the native EE search module if at all possible.

From searching I've seen various code snippets altering the _gaq.push(['_trackPageview' line in the analytics code, but I'm not sure exactly how to implement this and would rather not mess up the main site tracking, so I was hoping someone may have some working code for this.

Many thanks for your time.

19

I have a comment in the Search module docs on this. Inside your Analytics tracking code block, you can do something like this (change the segment conditionals to match your specific case)

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-X']);
_gaq.push(['_trackPageview']{if segment_1 == 'search' && segment_2 == 'results'}, ['/search/results/?q={exp:search:keywords}']{/if}); 
| improve this answer | |
  • 2
    brilliant derek many thanks - my googling had not thrown that up, don't know why i hadn't thought of checking the docs for this! – Tidy Nov 26 '12 at 20:32
4

"Super search" supports human-readable ( and therefor analytics-friendly ) queries: http://www.solspace.com/docs/addon/c/Super_Search

| improve this answer | |
  • Thanks Janvl - I should have said that I need to stick with the standard EE search module here - I've updated my question with that info. – Tidy Nov 26 '12 at 16:46
3

This is possible, but you need to modify the GA tracking code on EE's search results template.

There is a wiki article on how to do this, but with the launch of the new Ellis Lab site you'll have have to take a look at Google's cached version.

read the cached wiki article

UPDATE: Here's a link to a Gist of the same article in case the wiki doesn't make it back online

| improve this answer | |
  • thanks for this mjr and for going to the trouble of digging up the cached link. – Tidy Nov 26 '12 at 20:34
  • good call on the gist – mjr Nov 29 '12 at 14:44
1

EE does have native search keyword logging. Here's a link to the info in the docs.

| improve this answer | |
  • No worries. I had a hunch that wasn't the URL you were aiming for. :) – Dom Stubbs Nov 26 '12 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.