A client asked me recently if we could set up Google Analytics to track her site search. I told her that Google Analytics couldn't do that and she quickly pointed me to the docs that describe how it's done.
My favorite clients are the ones I learn from.
Google Analytics tracks a query string in a URL. On this site, we had Super Search set up with a post method and no query string. We had to do a few simple things to get this working:
- Make sure we were using Super Search 1.4.0 or higher. It won't work with older versions.
- Change the form method to "get".
- Change the form action to add a "search" segment at the end of the URL: action="{path=search/results/search}".
- Set up Google Analytics to track searches. Directions are here. Once it is set up, results can be found in Content -> Site Search.
This would not be possible with ExpressionEngine's native search, which uses a temporary hash for search results.



7 Comments
eyevariety
Sep 1, 2011 11:23 am
#1
It took me a while to figure this one out back in the day. I think it would be great if Solspace documented best practices like this for each addon. The open ended nature of each addon just begs for it.
Thanks for sharing.
Joel Bradbury
Sep 7, 2011 2:10 am
#2
We’re looking at doing just that with the docs, and we’d love to hear any other thoughts you might have on how we can improve the docs / examples to make it easier for devs.
jdmcleod
Sep 20, 2011 7:37 pm
#3
I have attempted to get this to work, but whenever I set my form action to “get” I get an error “Invalid GET Data - Array”.
Any workarounds?
Nicolas Bottari
Solspace
Sep 21, 2011 6:42 am
#4
Using method=“get” can result in errors, especially if passing array data (eg. category[]). I would use method=“post”, but set Super Search to display its query results in the URL. I assume this would get picked up by GA as well
kailystree
Jan 10, 2012 11:44 am
#5
Thank you. This is quite helpful. I didn’t know Analytics does that.
HopsStudios
Mar 23, 2012 5:26 pm
#6
So, is what you’re saying, is that the URL *must* contact a query string for Google Analytics to work?
TTFN
Travis
Nicolas Bottari
Solspace
Mar 24, 2012 9:54 pm
#7
@Travis
Google Analytics reads the URL to register a hit. With searches, you must provide a “query parameter” in your URL for GA to understand it as a search to record. You can set up which words will trigger site search tracking in GA’s settings. See the directions link in the main post