By Scott Thomas
Perhaps you saw the articles a couple of weeks ago, indicating that Google had officially announced that its Google Analytics product was now able to track social media interaction. As the linked article mentioned, this is a welcome addition to the built-in capability of the Google +1 button to track clicks. However, this bit of news was soon overshadowed by all the buzz surrounding the (as yet, despite being enormous, and frequently discussed) beta of Google+ – the new Google social platform.
We had seen the articles and sort of filed them away for future reference. A friend got in touch last week, however, asking how to implement this, and indicating that the information wasn’t very clear. After reading the official documentation, we certainly had to agree. However, after a bit of testing, we were able to get it to work, and provide the results here, in case you’d like to use Google Analytics to track various social interaction on your website, blog, or whatever.
What we’re trying to accomplish
To be clear, the objective is to add some JavaScript to our website, blog, or whatever, that will allow us to use Google Analytics to track when someone clicks on social media buttons on the page – such as a Facebook Like button, or a Facebook share link, or a Twitter follow or Tweet button, or any other similar item. For those who enjoy figuring this out for themselves, the documentation can be found here.
For the rest of us, there are three pieces of code to insert (We haven’t attempted to use anything but Facebook and Twitter – though the same principle would work with any; also Google +1 forwards data to GA automatically, so there is no need to do anything special for it), and of course a couple of prerequisites.
Prerequisites:
Code needed to make this work:
In the section of the page (I would suggest after the GA code, but don’t know if that is mandatory), add: <script src=“ga_social_tracking.js” type=“text/javascript”></script><br /> <script src=“http://platform.twitter.com/widgets.js" type=“text/javascript”></script><br /> <script src=“http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<div id=“fb-root”></div><br /> <fb:like href=“http://www.YOURDOMAIN.com/PAGETOTRACK" send=“true” show_faces=“false” layout=“button_count”></fb:like> Then change YOURDOMAIN.com to your domain, and PAGETOTRACK to the path and page you want to have the button track. Do not omit the div with the fb-root id.
<p>
</p>
<li>
Just before the closing body tag on the page, put <p>
<code><script><br />
_ga.trackSocial();<br /> </script>
<p>
Done and done.
</p>
<p>
Social activities seem to show up in the new Google Analytics within an hour or so.
</p>