Use Google to Track the Popularity of Your Images

Finding your Creative Center with Google
by Daron Shade

A few months ago, I recommended that you sign up and implement Google Analytics. By now, I’m sure you are all getting pretty proficient with GA and have been watching your traffic and are beginning to understand your visitors better.

You’ve learned about all of the strengths and the few glaring weaknesses of GA that get in the way of truly understanding what drives traffic to your site. You’re a photographer and your work is entirely image-based. GA won’t tell you the search phrases that visitors used to find you on Google Image Search! How do you know if your title and alt tags are working their magic? How do you know if your Meta descriptions and on-page content are working together to bring visitors to your images? You don’t! But you want to know, right? Read on.

I had been struggling with the lack of image search information for many months. For some unknown reason, Google considers it’s own image search engine a referrer and not a true search. I began hacking the GA code and API, and found a way to force it to do what we need. I’ve been testing for a few months and am very happy with the result. Here’s a view of some recent traffic for the search engine images.google.com:

Before this hack, I had no idea that I was getting traffic for any of these keywords.

So, how is it done? It’s actually pretty simple. Google in their infinite wisdom has kept their code very open and friendly to modification. All we need to do is tell it that domain names images.google.* are all search engines. The behind-the-scenes magic does the heavy lifting for us! It took me quite a while to come up with working code, but as soon as I did, I searched and found that some other people were able to do it also.

Without getting more deeply into the details, let’s address the ‘how-to’ of rolling this into your own site.

Simply take the code code below and use it to replace your existing GA code on each page of your site. Please note the “UA-xxxxxxxx-x” – that needs to be replaced with your existing account number for this code to work.

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

<script type="text/javascript" charset="utf-8">
try {
var pageTracker = _gat._getTracker("UA-xxxxxxxx-x");
var ref = document.referrer;
if (ref.search(/images.google/) != -1 && ref.search(/prev/) != -1) {
var regex = new RegExp("images.google.([^\/]+).*&prev=([^&]+)");
var match = regex.exec(ref);
pageTracker._clearOrganic();
pageTracker._addOrganic("images.google."+ match[1],"q");
pageTracker._setReferrerOverride("http://images.google." + match[1] + unescape(match[2]));
}
pageTracker._trackPageview();
} catch(err) {}
</script>

It’s that simple! Update the code and you will start collecting detailed information about Google Image Searches!

Next time, we will discuss paid vs. organic search engine results and if you should be doing both.

– –

Thanks Daron. This neat little trick will be very handy in tracking your images – and what it is people like about your work.

You can catch Daron at his website, you can follow me on Twitter, and visit the Learn to Light site to get more information on the workshops and other cool things coming up soon.

Print Friendly

About 

I am in love with light.

Also known as Don Giannatti, photography has been the focus of my life for most of my adult years. I have written three books for Amherst Media (available on Amazon and Barnes & Noble: keyword 'don giannatti'. Lighting Essentials is my flagship blog and ezine with a slightly different slant than most photography related blogs. If you are interested in becoming a better photographer, check out www.project52.org. Thanks for visiting.

Related Posts: