Getting Google Analytics to extract keywords from Google Image searches
Google Analytics doesn't get the keywords people used to find your site using Google Image search, and thus labels them as "referral" instead of as "organic".
Google Image search gives you referral URL's that aren't really readable. The query string that the searcher used to get to that referring URL is hidden somewhere deep down in this URL in the &prev variable. Since Google Analytics can't read that, it doesn't get the keyword out of it. That's the reason why it thinks it's a normal reffering URL, and Google image search will show up as a referral instead of organic search in your statistics.
Now if your site relies on image search for a significant part of it's traffic, you'll probably want to know which keywords were used. I've been working hard to find a way to get that fixed, and the solution I have now involves a customized urchin.js, and adding some extra search engines. You will have to put this urchin.js on your own server, but it will still call the small image file from the Google Analytics servers. It basically "rewrites" the referrer to the original Google Image search URL, so no other information is lost.
Next to the customized urchin.js you need the latest version of my custom_se.js, to add all the different Google image search domains. The list of search engines in that file is an array, and Google Analytics will stop at the first encounter of a match, which is why the image subdomains have to be on top. Otherwise, all image searches would look like plain Google searches.
Your code should look something like this:
<script src="http://www.example.com/urchin.js" type="text/javascript"></script> <script src="http://www.example.com/custom_se.js" type="text/javascript"></script> <script type="text/javascript"> _uacct = "UA-******-*"; urchinTracker();
And here are the files to download:
Adding these will make the searches show up in Google Analytics as coming from images.google.com, images.google.nl etc. etc. Have fun with it!
This post will tell you how to do this with the new ga.js script.





by Peter van der Graaf on 4 August, 2007 at 11:22
Hello Joost,
I've seen periodic changes in the Google Analytics javascript. Do you plan to periodically update your custom version?
by Joost de Valk on 4 August, 2007 at 13:50
Yes of course :) (until I find a way to do this without altering urchin.js)
by Peter van der Graaf on 5 August, 2007 at 11:10
Then I'm more then willing to test you script. Thanks.
by Jose on 4 September, 2007 at 21:46
I just noticed this defect on google analytics too. Is there a reason for them not to fix it? Thanks
Pingback: Google Analytics and Google Image search: revisited - SEO Blog - Joost de Valk
by Tom on 24 October, 2008 at 10:54
Is this the only change you made? I can keep the JS up to date myself if it is:
if (_ubd.referrer.search(/images.google/) != -1) {var ref = _ubd.referrer;
var tldregex = new RegExp("images.google.([^\/]+)");
var tldmatch = tldregex.exec(ref);
var imgregex = new RegExp("&prev=([^&]+)");
var refmatch = imgregex.exec(ref);
refmatch = refmatch[1].replace(/%26/g,"&");
refmatch = refmatch.replace(/%3F/g,"?");
refmatch = refmatch.replace(/%3D/g,"=");
_ur = "http://www.images.google." + tldmatch[1] + refmatch;
} else {
_ur=_ubd.referrer;
}
by Tom on 24 October, 2008 at 10:56
Never mind, just spotted the trackback from your later post. You should add a notice to this one. :-)
Pingback: 30+ Google Analytics Tools, Goals, Segments, Filters, Hacks & Resources | SEOptimise
Pingback: 30+ Google Analytics Tools, Goals, Segments, Filters, Hacks & Resources | SEO trouble