Are you tracking social shares with Google Analytics?

Why check your social shares and interactions exclusively on AddThis, ShareThis, Facebook, or any other website when you can bring your share data into Google Analaytics. With this data inside of Analytics, you will gain invaluable insight into your social marketing efforts and the ability to setup goal tracking and other fun stuff.

Tracking AddThis & ShareThis is easy. Tracking Facebook likes and Twitter follows? That presents a problem. Before inserting any codes below, I would HIGHLY recommend you read this Google Analytics help page if you are comfortable working with javascript.

If you want to track Twitter & Facebook, I would recommend looking at:
Skip to:

  1. Facebook
  2. Twitter
  3. AddThis Integration
  4. ShareThis Integration

Facebook Integration

The code below will allow for Analytics to track Likes, Unlikes, and Messages for an Asynchronous FB Like button. Place the code within your websites Footer, below your Asynchronous Facebook Like button.

window.fbAsyncInit = function() {
    FB.init({xfbml: true});
    FB.Event.subscribe('edge.create', function(targetUrl){
        _gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
    FB.Event.subscribe('edge.remove', function(targetUrl){
        _gaq.push(['_trackSocial', 'facebook', 'unlike', targetUrl]);
    FB.Event.subscribe('message.send', function(targetUrl) {
        _gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);

If you want to track more actions, or track other implentations, check out these great resources:

  1. Social Media Examiner
  2. Napkyn

Twitter Integration

The code below will track Tweets, Clicks, Follows, Retweets, and Favorites. (from github).

var event_names = {
"click" : "" ,
"tweet" : "",
"retweet" : "source_tweet_id",
"follow" : "screen_name",
"favorite" : "tweet_id"

for(var event_name in event_names)
if(event_names.hasOwnProperty(event_name)){, function(intent_event){
var label = intent_event.type==="click" ? intent_event.region : ( ?[event_names[intent_event.type]] : "" ;
_gaq.push(["_trackEvent", "twitter_web_intents", intent_event.type, label ]);

More Resources:


AddThis Analytics Integration

I found their implementation page confusing. If your not using Google Analytics Asynchronous tracking code, now is a good time to update it. After switching to the Asynchronous tracking code, simply add the following code BEFORE your AddThis code:

<script type="text/javascript">
   var addthis_config = {
      data_ga_property: 'UA-XXXXXX-XX',
      data_ga_social: true

Replace ‘UA-XXXXXX-XX’ with your Google Analytics ID (the last 2 digits are the site ID, so make sure if updating multiple sites you are using the proper ID).

ShareThis Analytics Integration

ShareThis works just like AddThis did above. Located your ShareThis code and add the following line before the default javascript:

<script type="text/javascript">

Replace “UA-XXXXXX-XX” with your Google Analytics ID.

I hope this post inspires you to experiment further with Google Analytics and the types of tracking you can do with it. In addition to tracking the standard actions above, I would recommend that you go even further and experiment with tracking other events – like blog comments & file downloads.

Data is king!

This entry was posted in Social Media. Bookmark the permalink.

One Response to Are you tracking social shares with Google Analytics?

    Leave a Reply

    Your email address will not be published. Required fields are marked *