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:
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 my best selling books on Attribution Modelling
Learn to implement attribution modelling in your organisation
Understand the customer purchase journey across devices
Determine the most effective marketing channels for investment
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):
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-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:
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):
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.
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):
Note: You can’t track Twitter social actions through the Tweetmeme button or other Twitter type buttons.
<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-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):
"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 BeyondSECOND EDITION OUT NOW!
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.
About the Author
Himanshu Sharma
Founder, OptimizeSmart.com
Over 15 years of experience in digital analytics and marketing
Author of four best-selling books on digital analytics and conversion optimization
Nominated for Digital Analytics Association Awards for Excellence
Runs one of the most popular blogs in the world on digital analytics
Consultant to countless small and big businesses over the decade
Learn and Master Google Analytics 4 (GA4) - 126 pages ebook
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.