Google Analytics Social Tracking – Twitter, Facebook, Google Plus & Linkedin

It is very important that before we move forward, you understand the difference between event tracking & social tracking and difference between normal users’ interactions & social interactions:

1. Event tracking is implemented by calling the _trackEvent() method whereas social tracking is implemented by calling the _trackSocial() method.

2. Event reports are available in the content section and social reports are available in the visitors section of the new Google analytics interface.

Event Tracking Report

2. To send social interaction data to Google Analytics we call the _trackSocial() method wherever we have added the share button/social plugin:

_gaq.push(['_trackSocial', network, socialAction, opt_target]);

Where,

network => Name of the social network being tracked e.g. Facebook, Twitter, LinkedIn etc. This parameter is required to be passed to the trackSocial method.

socialAction => Type of the social action being tracked e.g. Like, unlike, send, Tweet etc. This parameter is required to be passed to the method.

opt_target => This parameter is optional. It is a URL which receives the social action.

Please note: _trackSocial seems to track only those social sharings which were done through social plugin/share button on your website. It doesn’t seem to track re-tweets or sharing done on some third party site or third party plugins like tweetmeme. So if your blog post is tweeted 10 times via a share button on your website and then later re-tweeted 65 times then also _trackSocial counts only 10 tweets. So in short, i don’t see social interactions being tracked across the web. This is not what i was expecting from Google :(

 

Tracking Google +1 Social interactions

Google analytics automatically tracks the social interactions associated with Google +1s once you have placed both the Google +1 button and latest version of the Google Analytics tracking code on the web pages of your website. These interactions are automatically captured in the social reports of Google Analytics. So you don’t have to place any tracking code for Google +1 button. However you must add this button to your web pages. Following is the asynchronous JavaScript code for the Google +1 button which you can use to place the button on your web pages:


 

 

Tracking Facebook Social Interactions

For facebook, social actions can be: ‘like’,'unlike’, ‘follow’, ‘send’,'comment’ etc. Through ‘like’ button a user can share your web page on his facebook profile with just one click. Through send button a user can send (share) your web page to his friends. Similarly through comment button a user can comment on any web page of your website. If you want to track all social actions provided by facebook then you need to install all social plugins of facebook. You can get the list of such plugins here.

Please note: you can track only those social actions for which you have installed/placed social plugin on your website. For e.g. if you want to track facebook comments, then you first need to install facebook comments plugin on your website. I have added facebook ‘like’ and ‘send’ buttons to my blog and following is the button code:

Please note: I have added following additional line of code to the facebook ‘like’ and ‘send’ button code:

<script type=”text/javascript”>_ga.trackFacebook();</script>

ga.trackFacebook() is a Google analytics function through which you can give your users the ability to override the tracker name. Here is how the function code looks like:


Now according to Google’s ‘Social Interaction Analytics‘ documention, to capture facebook’s social actions in Google analytics, you need to call the facebook’s edge.create event and create a call back function which can send the social interactions data to Google Analytics via _trackSocial method. Here is the code for that:


Through the code above you can track facebook ‘like’, ‘unlike’, ‘send (share)’, ‘comment’ and ‘uncomment’ social actions. Finally your facebook button and tracking code will look like this:


Copy-paste this code wherever you want to add your facebook ‘like’ and ‘send’ button.

Please Note: You will be able to track ‘comment’ and ‘uncomment’ social actions only when you have installed Facebook comments social plugin on your web pages.

 

Tracking Twitter Social Interactions

For twitter, social actions can be: ‘tweet’, ‘click’, ‘follow’ etc. If you want to track all social actions provided by twitter then you need to install the official twitter button on your web pages. You can’t track twitter social actions through Tweetmeme button or other twitter type buttons. I have added the official twitter button to my blog using the following button code:

You can get your twitter button code from here.

Now according to Google’s ‘Social Interaction Analytics‘ documention, to capture twitter’s social actions in Google analytics, you need to bind a call back function to the tweet event. Here is the code for that:


Through the code above you can track twitter’s ‘tweet’, ‘follow’, ‘retweet’ (though i have not seen it working), ‘favorite’ and ‘click’ social actions. Finally your twitter button and tracking code will look like this:

Copy-paste this code wherever you want to add your official twitter button.

Please Note: There is no need to add following line of code in the head section of your document to enable Google Analytics Social tracking:


 

Tracking LinkedIn Social Interactions

To track Linkedin social actions via Google Analytics you first need to install the official linkedin share button on your web pages. Unfortunately linkedin call back function ‘data-success’ doesn’t work. This has been an issue for the last several months. If ever this call back function starts working then the following code might track linkedin’s social actions:


If you know any other way to track linkedIn social interactions then please share in the comments below. That’s all folks. If you like this post then you should subscribe to my blog and follow me on twitter.

Related Posts

 

 

Himanshu Sharma About the Author: is the founder of seotakeaways.com which provides SEO Consulting, PPC Management and Analytics Consulting services to medium and large size businesses. He holds a bachelors degree in ‘Internet Science’, is a member of 'Digital Analytics Association', a Google Analytics Certified Individual and a Certified Web Analyst. He is also the founder of EventEducation.com and EventPlanningForum.net.

My business thrives on referrals, so I really appreciate recommendations to people who would benefit from my help. Please feel free to endorse/forward my LinkedIn Profile to your clients, colleagues, friends and others you feel would benefit from SEO, PPC or Web Analytics.