Google Analytics Social Tracking – Twitter, Facebook, Google Plus and LinkedIn

In this post you will learn to track Google +1, Facebook likes, Facebook sends, Facebook unlikes, Twitter tweets, Twitter follows and LinkedIn shares in Google Analytics.

But before we move forward, you need to understand the difference between event tracking & social tracking and the 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 under the ‘Behavior’ menu and Social reports are available under the ‘Acquisition’ menu in your Google Analytics account.

The ‘_TrackSocial()’ method

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]);

Here,

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.

_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.

In short, I don’t see social interactions being tracked across the web. This is not what I was expecting from Google.

Get the E-book (52 Pages)

Get the E-Book (37 Pages)

Tracking Google +1 social interactions

Step-1: Make sure you are using the latest Google Analytics Asynchronous Tracking Code on your website.

Step-2: Copy the Google +1 button code from here and paste it wherever you want to display the button on your website. Google Analytics automatically tracks the social interactions associated with Google +1s once you have installed the Google +1 button on your website.  So you don’t need to place any special tracking code for Google +1 button.

Step-3:  After few days/weeks, go to ‘Plugins’ report (under Traffic Sources > Social) in your Google Analytics account. Then click on the primary dimension ‘Social Source and Action’. You will see the following report (provided your tracking is set up correctly):

linkedin-share

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.
  • Through ‘comment’ button a user can comment on any web page of your website.

Step-1: Make sure you are using the latest Google Analytics Asynchronous Tracking Code on your website.

Step-2: Upload ‘ga_social_tracking.js‘ file to your web server. You can grab this file from here.

Step-3: Enable Social Tracking by adding the following code after your Google Analytics Tracking Code and before the </head> tag:

<!-- Enabling Google Analytics Social Tracking code Starts Here -->
<script type="text/javascript" src="https://www.your-domain.com/wp-content/uploads/ga_social_tracking.js"></script>
<!-- Enabling Google Analytics Social Tracking code Ends Here -->

The final code will look like the following:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-x']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'https://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- Enabling Google Analytics Social Tracking code Starts Here -->
<script type="text/javascript" src="https://www.your-domain.com/wp-content/uploads/ga_social_tracking.js"></script>
<!-- Enabling Google Analytics Social Tracking code Ends Here -->
</head>

Don’t copy past this code without modification.

Replace “UA-xxxxxx-x” with your Google Analytics account number and ‘www.your-domain.com’ with your website address where you have installed the ‘ga_social_tracking.js’ file.

Step-4: Install the Facebook ‘like’ button from here. The ‘Like’ button code will look something like this:

<fb:like send="true" show_faces="false" layout="button_count" width="150"></fb:like>


Step-5
: Add following line of code just before before the <fb:like /> tag:

<script src="https://connect.facebook.net/en_US/all.js#xfbml=1&appId=501839739845103"></script><script type="text/javascript">_ga.trackFacebook();</script>

So the final code will look like this:

<script src="https://connect.facebook.net/en_US/all.js#xfbml=1&appId=501839739845103"></script><script type="text/javascript">_ga.trackFacebook();</script><fb:like send="false" layout="button_count" width="150" show_faces="false"></fb:like>

Don’t copy-paste this code without modifying it first.

Here The “#appId=xxxxxxxxxxx” is a random app ID that Facebook generates which allows you to access Insights for the button.

Don’t use my appID. When you create your own Facebook ‘like’ button, Facebook will generate an appId for you. Use that appID.

Note: The appId is not a requirement for the ‘like’ button to work.

Step-6: Copy-paste the modified Facebook ‘like’ button code wherever you want to display the Like button.

Step-7: After a few days/weeks, go to ‘Plugins’ report (under Traffic Sources > Social) in your Google Analytics account. Then click on the primary dimension ‘Social Source and Action’. You will see the following report (provided your tracking is set up correctly):

facebook-like

If you want to track all the social actions provided by Facebook then you need to install all the social plugins of Facebook. Get the list of plugins.

Note: you can track only those social actions for which you have installed social plugins 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.

If you are using Universal Analytics on your website, then checkout this article to track Facebook social interaction: Tracking Facebook Social Interactions with Google Analytics and Google Tag Manager

Tracking Twitter social interactions

For Twitter, social actions can be: ‘tweet’, ‘click’, ‘follow’ etc.

Step-1: Make sure you are using the latest Google Analytics Asynchronous Tracking Code on your website.

Step-2: Make sure that the file  ‘ga_social_tracking.js‘ is uploaded on your web server.

Step-3: Make sure you have enabled the Social Tracking as explained above.

Step-4: Install the official twitter button on your website. The ‘twitter’ button code will look something like this:

<!-- Twitter button code starts here -->
<a href="https://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="seohimanshu">Tweet</a><script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>
<!-- Twitter button code ends here -->

Don’t copy-past this code without modification. Use your own Twitter handle.

Step-5: Copy paste the following code just before the </head> tag:

<!-- Load Twitter JS-API asynchronously -->
<script>
(function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = 'https://platform.twitter.com/widgets.js';
// Setup a callback to track once the script loads.
twitterWidgets.onload = _ga.trackTwitter;
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>


Step-6:
After a few days/weeks, go to ‘Plugins’ report (under Traffic Sources > Social) in your Google Analytics account. Then click on the primary dimension ‘Social Source and Action’. You will see the following report (provided your tracking is set up correctly):

twitter-interactions

Note: You can’t track Twitter social actions through the Tweetmeme button or other Twitter type buttons.

If you are using Universal Analytics on your website, then checkout this article to track Twitter social interaction: Tracking Twitter and Linkedin Social Interactions in Google Analytics

Tracking LinkedIn social interactions

Step-1: Make sure you are using the latest Google Analytics Asynchronous Tracking Code on your website.

Step-2: Make sure that the file  ‘ga_social_tracking.js’ is uploaded on your web server. 

Step-3: Make sure you have enabled the Social Tracking as explained above.

Step-4: Add the following code after your Social Tracking Code and before the </head> tag:

<!-- LinkedIn Share Button tracking code starts here-->
<script type="text/javascript">
function LinkedInShare() {
_gaq.push(['_trackSocial', 'LinkedIn', 'Share']);
}
<!-- LinkedIn Share Button tracking code ends here-->

The final code will look like the following:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-x']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'https://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- Enabling Google Analytics Social Tracking code Starts Here -->
<script type="text/javascript" src="https://www.your-domain.com/wp-content/uploads/ga_social_tracking.js"></script>
<!-- Enabling Google Analytics Social Tracking code Ends Here -->
<!-- LinkedIn Share Button tracking code starts here-->
<script type="text/javascript">
function LinkedInShare() {
_gaq.push(['_trackSocial', 'LinkedIn', 'Share']);
}
<!-- LinkedIn Share Button tracking code ends here-->
</head>

Don’t copy-past this code without modification.

Replace “UA-xxxxxx-x” with your Google Analytics account number and ‘www.your-domain.com’ with your website address where you have installed the ‘ga_social_tracking.js’ file.


Step-4:
 Install the official LinkedIn share button on your web page(s). The button code will look like this:

<script src="//platform.linkedin.com/in.js" type="text/javascript">
 lang: en_US
</script>
<script type="IN/Share" data-counter="right"></script>


Step-5:
 Modify the LinkedIn button code by adding: data-onsuccess="LinkedInShare" like this:

<!-- Linkedin button & tracking code starts here -->
<script src="https://platform.linkedin.com/in.js" type="text/javascript"></script>
<script type="IN/Share" data-counter="right" data-onsuccess="LinkedInShare"></script>
<!-- Linkedin button & tracking code ends here -->


Step-6:
  Copy-paste the modified button code wherever you want to display the LinkedIn button.


Step-7:
After a few days/weeks, go to ‘Plugins’ report (under Traffic Sources > Social) in your Google Analytics account. Then click on the primary dimension ‘Social Source and Action’. You will see the following report (provided your tracking is set up correctly):

linkedin-share

If you are using Universal Analytics on your website, then checkout this article to track LinkedIn social interaction: Tracking Twitter and Linkedin Social Interactions in Google Analytics

Related articles

  1. Understanding Facebook Referral traffic in Google Analytics
  2. Learn to correctly track Facebook Referral traffic in Google Analytics
  3. Tracking Facebook ‘Likes’ and ‘Unlikes’ in Google Analytics
  4. Why Facebook and Google Analytics data do not match
  5. Complete Guide to Google Analytics for Facebook

Other articles on specialized tracking in Google Analytics

  1. Ecommerce Tracking in Google Analytics – Tutorial
  2. Event Tracking via Google Tag Manager – Tutorial
  3. Event Tracking in Google Analytics – Tutorial
  4. Guide to Google Analytics Store Visits Tracking
  5. Offline Conversion Tracking in Google Analytics – Tutorial
  6. Implementing E-Commerce Tracking via Google Tag Manager
  7. Tracking Virtual Pageviews in Google Tag Manager – Tutorial
  8. YouTube Video tracking via Google Tag Manager
  9. How to Use Keyword Hero to Reveal Not Provided Keywords in Google Analytics
  10. Virtual pageviews in Google Analytics – Tutorial
  11. Google Analytics and YouTube Integration Tutorial
  12. Google Analytics for Facebook Tutorial
  13. Google Analytics Cross Domain Tracking Explained Like Never Before
  14. Using multiple Google Analytics tracking codes on web pages
  15. The one thing that you don’t know about PayPal.com and the referral exclusion list
  16. Calculated Metrics in Google Analytics – Tutorial
  17. Creating your own Google Analytics Tag Auditing System
  18. Tracking Site Search without Query Parameter in Google Tag Manager
  19. Tracking true referrals in Google Analytics when using PayPal and other payment gateways
  20. Phone Call Tracking in Google Analytics and Beyond
  21. Learn to Track Qualified and Won Leads in Google Analytics
  22. Introduction to Postbacks in Google Analytics
  23. Google Analytics Recurring Revenue and Subscriptions Tracking Tutorial
  24. How to track the impact of cookie consent on website traffic in Google Analytics
  25. Tracking Offline Conversions in Google Ads
  26. Implementing Scroll Tracking via Google Tag Manager
  27. Scroll Tracking via Scroll Depth Trigger in Google Tag Manager
  28. Site Search Tracking In Google Analytics Without Query Parameters
  29. Video Tracking via YouTube Video Trigger In Google Tag Manager
  30. How to Correctly Measure Conversion Date & Time in Google Analytics
  31. Google Analytics Social Tracking – Twitter, Facebook, Google Plus and LinkedIn
  32. Google Analytics Cross Domain Tracking (ga.js)
  33. Tracking Twitter and Linkedin Social Interactions in Google Analytics
  34. Creating Content Group in Google Analytics via tracking code using gtag.js
  35. Tracking Site Search in Google Analytics with Query Parameters
  36. Understanding site search tracking in Google Analytics
  37. Creating and Using Site Search Funnel in Google Analytics
  38. Learn to Setup Facebook Pixel Tracking via Google Tag Manager
  39. Setting up & Tracking AMP Pages in Google Analytics
  40. Setting up Sales Funnel across websites in Google Analytics
  41. Regular Expressions (Regex) for Google Analytics & Google Tag Manager – Tutorial

Do you know the difference between Digital Analytics and Google Analytics?


99.99% of course creators themselves don’t know the difference between Digital analytics, Google Analytics (GA) and Google Tag Manager (GTM).

So they are teaching GA and GTM in the name of teaching Digital analytics. They just copy each other. Monkey see monkey do.

But Digital analytics is not about GA, GTM. It is about analyzing and interpreting data, setting up goals, strategies, and KPIs.

It’s about creating a strategic roadmap for your business.



Digital Analytics is the core skill. Google Analytics is just a tool used to implement ‘Digital Analytics’.

You can also implement ‘Digital analytics’ via other tools like ‘adobe analytics’, ‘kissmetrics’ etc.

Using Google Analytics without a good understanding of ‘Digital analytics’ is like driving around in a car, in a big city without understanding the traffic rules and road signs.

You are either likely to end up somewhere other than your destination or get involved in an accident.



You learn data analysis and interpretation from Digital analytics and not from Google Analytics.

The direction in which your analysis will move will determine the direction in which your marketing campaigns and eventually your company will move to get the highest possible return on investment.

You get that direction from ‘Digital analytics’ and not from ‘Google Analytics’.



You learn to set up KPIs, strategies and measurement framework for your business from ‘Digital analytics’ and not from ‘Google Analytics’.

So if you are taking a course only on 'Google Analytics’, you are learning to use one of the tools of ‘Digital analytics’. You are not learning the ‘Digital analytics’ itself.

Since any person can learn to use Google Analytics in a couple of weeks, you do no get any competitive advantage in the marketplace just by knowing GA.


You need to know a lot more than GA in order to work in the digital analytics and marketing field.


So what I have done, if you are interested, is I have put together a completely free training that will teach you exactly how I have been able to leverage digital analytics to generate floods of news sales and customers and how you can literally copy what I have done to get similar results.



EXCLUSIVE FREE TRAINING...

"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."



Here’s what we’re going to cover in this training…

#1 Why digital analytics is the key to online business success.

​#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.

#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.

#4 ​Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.

#5 The number 1 reason why conversion optimization is not working for your business.

#6 How to advertise on any marketing platform for FREE with an unlimited budget.

​#7 How to learn and master digital analytics and conversion optimization in record time.



   

My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and Beyond
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

Himanshu Sharma

Digital Marketing Consultant and Founder of Optimizesmart.com

Himanshu helps business owners and marketing professionals in generating more sales and ROI by fixing their website tracking issues, helping them understand their true customers' purchase journey and helping them determine the most effective marketing channels for investment.

He has over 12 years of experience in digital analytics and digital marketing.

He was nominated for the Digital Analytics Association's Awards for Excellence. The Digital Analytics Association is a world-renowned not-for-profit association that helps organisations overcome the challenges of data acquisition and application.

He is the author of four best-selling books on analytics and conversion optimization:

error: Alert: Content is protected !!