Adam Right
Adam Right

Reputation: 985

Google Analytics Site Search

I use following sample URL pattern to search pattern on my web site.

http://www.mysite.com/search/someword No query strings, just clean URL..

How can set this URL to google analytics site search system?

Upvotes: 5

Views: 640

Answers (1)

Yahel
Yahel

Reputation: 37305

In theory, you should be able to create a profile filter to convert the URLs to use a query string. In practice, it turns out it's not possible, because Site Search gets processed before filters get processed.

Instead, what I've found that works is to just manipulate it in JavaScript so that you "fake" a query string directly from the browser.

Something like:

if(!location.pathname.match(/^\/search/)){
    _gaq.push(["_trackPageview"]);
}
else{
    _gaq.push(["_trackPageview", location.pathname.replace("/search/","/search?q=")]);
}

This would "fake" a query string with a key of q that you could then easily use the Site Search feature with.

Upvotes: 7

Related Questions