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
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.
- You will need to be able to add files to your web server, and edit the page(s) you want the tracking to work on.
- You must have Google Analytics tracking code on the site (I’m not sure if you have to use async code, but I suspect you do)
- You must be using the “New” GA – so it will show Social under the Visitors area.
- Grab the ga_social_tracking.js file from Google and put it in the same location as the page to be tracked (or change the path to the js file in the first script tag under Code step 1).
Code needed to make this work:
<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.
Just before the closing body tag on the page, put <p>
Done and done.
Social activities seem to show up in the new Google Analytics within an hour or so.