Way back in August of last year, I blogged about the ga.js file and how it automatically recognized 38 different websites as organic search engines. Today, June 2, 2009, the ga.js file now automatically recognizes 40 websites, pending Microsoft’s new engine “Bing.com” being added very soon to be number 41.
The team at Google Analytics can’t possibly keep up with every single website that appears on the internet, and depending on your own needs, you may find it useful to count a new website as an organic source of traffic, instead of counting the incoming traffic as a referral.
Perhaps you’d like to count your favorite website as an organic search engine? Or maybe you’d like to add any brand new search engine that comes out, like WolframAlpha or Bing.com, and you’d like to immediately start counting the traffic you get from it in the same report as Google and Yahoo? By making a very minor addition to the Google Analytics Tracking Code on all of your website’s pages, you can add as many new organic sources of traffic as you wish.
Here’s what that tracking code would look like on your website:
<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">
try {
var pageTracker = _gat._getTracker("UA-XXXXXX-X");
pageTracker._addOrganic("bing.com", "q");
pageTracker._trackPageview();
} catch(err) {}</script>
The new line of code that you should see is the _addOrganic call:
pageTracker._addOrganic("bing.com", "q");
There are two parts to the _addOrganic call – the first part (where it says “bing.com”) is the search engine domain name. The second part (where it says “q”) is the query parameter that displays the search term in the URL of your browser’s address bar.
The domain name is easy to get – simply grab your favorite site’s URL, remove the “www” prefix, and you have a domain name! The query parameter part may be tricky, depending on how your favorite website works. For example, on Bing.com, a search for “guitar hero accessories” returns this URL:
http://www.bing.com/search?q=guitar+hero+accessories&go=&form=QBLH
See the “q” right before my search term, behind the = symbol? Entering in “q” in the _addOrganic function will tell Google Analytics to look for “?q=” and a search term after the = symbol, so that you can get search term information from your new organic source as well as having it counted as an organic search engine!
Just keep in mind that not every website will have easy to find query parameters like the one from Bing.com does, and some websites will use something other than the letter “q”. For example, AOL.com uses “query”, and they use a different structure than Bing.com:
http://search.aol.com/aol/search?s_it=comsearch40&query=xbox+360&do=Search
When using _addOrganic, make sure to update the Google Analytics Tracking Code on EVERY PAGE of your website – if a person lands on a page that doesn’t contain the _addOrganic function, their traffic source will be counted as “referral”, not “organic”, so it’s vital to update this on all of your website’s pages, not just your homepage.
Hope you found this useful! Next time I will talk about how to modify your Google Analytics Tracking Code to treat certain keywords or referring websites as “direct” traffic. Stay Tuned!