Google Analytics Tracking Code for China – Update

 

Edited October 5, 2012: Since 360 Search has changed its domain to www.so.com, the GA code below has been updated to adapt to the new referrer string.Last year, we posted about editing your tracking code to make Google Analytics support Chinese search engines.With the addition of Qihoo 360 to the China search engine market, we thought it is time to update the GA tracking code again.

 

The following snippet will add support to Google Analytics for 360 Search, SoSo, Sogou and Youdao. This is based on a standard GA setup and does not include subdomain or multiple domains tracking. In such case you can just add line 4-7 into your own tracking code:

 

[javascript htmlscript=”true” highlight=”5,6,7,8″]
<script type=”text/javascript”>

var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-XXXXXX-X’]);
_gaq.push([‘_addOrganic’, ‘so.com’, ‘q’]);
_gaq.push([‘_addOrganic’, ‘soso’, ‘w’]);
_gaq.push([‘_addOrganic’, ‘sogou’, ‘query’]);
_gaq.push([‘_addOrganic’, ‘youdao’, ‘q’]);
_gaq.push([‘_trackPageview’]);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
[/javascript]

 

And of course, if you are still using the traditional snippet, here’s the update:

 

[javascript htmlscript=”true” highlight=”8,9,10,11″]
<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(“so.com”,”q”);
pageTracker._addOrganic(“soso”,”w”);
pageTracker._addOrganic(“sogou”,”query”);
pageTracker._addOrganic(“youdao”,”q”);
pageTracker._trackPageview();
} catch(err) {}
</script>
[/javascript]