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.

4 Answers 4


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}); 
  • 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!
    – Janine
    Commented Nov 26, 2012 at 20:32

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

  • 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.
    – Janine
    Commented Nov 26, 2012 at 16:46

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

  • thanks for this mjr and for going to the trouble of digging up the cached link.
    – Janine
    Commented Nov 26, 2012 at 20:34
  • good call on the gist
    – mjr
    Commented Nov 29, 2012 at 14:44

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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