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: https://gist.github.com/2005331
Skip to:
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.
<script> 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]); }); }; </script>
If you want to track more actions, or track other implentations, check out these great resources:
Twitter Integration
The code below will track Tweets, Clicks, Follows, Retweets, and Favorites. (from github).
<script> (function(){ 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)){ twttr.events.bind(event_name, function(intent_event){ if(intent_event) { var label = intent_event.type==="click" ? intent_event.region : (intent_event.data) ? intent_event.data[event_names[intent_event.type]] : "" ; _gaq.push(["_trackEvent", "twitter_web_intents", intent_event.type, label ]); } }); } } }()); </script>
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 }; </script>
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"> stLight.options({ publisherGA:"UA-XXXXXX-XX" }); </script>
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!
One Response to Are you tracking social shares with Google Analytics?