tracking site searches in google analytics



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 instead of

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.


Posted 2012-11-26T16:11:51.967

Reputation: 560



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}); 

Derek Hogue

Posted 2012-11-26T16:11:51.967

Reputation: 17 344

2brilliant 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 – 2012-11-26T20:32:59.093


"Super search" supports human-readable ( and therefor analytics-friendly ) queries:


Posted 2012-11-26T16:11:51.967

Reputation: 1 154

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 – 2012-11-26T16:46:10.577


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


Posted 2012-11-26T16:11:51.967

Reputation: 575

thanks for this mjr and for going to the trouble of digging up the cached link. – Tidy – 2012-11-26T20:34:04.963

good call on the gist – mjr – 2012-11-29T14:44:18.413


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


Posted 2012-11-26T16:11:51.967

Reputation: 12 118

No worries. I had a hunch that wasn't the URL you were aiming for. :) – Dom Stubbs – 2012-11-26T23:12:21.747