Social Media is a vital part to a successful online presence.
As companies continue to realise its importance, they are adding more and more social buttons to their websites.
Those buttons might consist of typical share buttons that you see at the end of posts, or they might consist of Twitter’s ‘follow’ button, or LinkedIn’s follow button.
No matter what buttons you include on your website, you should be tracking how many people click on them, and which pages the buttons have most success on.
This article will take you through the steps to set up the Google Analytics Social Plugin report within your WordPress website.
A few requirements before I continue:
- This is for a WordPress website, but you can use the code elsewhere
- You must be able to access the files of your website – not just the admin screen
- You must have Google Analytics set up to access the reports
Now we have the requirements out of the way, we can get into the good stuff!
Setting up the script
The following instructions will allow you to track the social interactions on buttons from Facebook, Twitter, LinkedIn and Google+.
Downloading the main script
First things first, you need to download this JavaScript file.
Upload the social-tracking.js file to your server – I put mine in a folder called ‘js’.
Editing your header
To get the script running, you need to edit your header.php file – This can be found in /wp-content/themes/your-theme/.
Open this file with a text editor – like Notepad or Notepad++. (You can also do this within the WordPress admin by going to ‘Appearance > Editor’ in the left menu.)
You need to enter the following code just before the </head> tag:
Please click here to access the code.
You need to update the UA-XXXXX-X with your Google Analytics number – This can be found by going into the analytics data for your website, and clicking ‘Admin’ in the top right.
You also need to double check the path to file you uploaded is correct.

Editing your footer
Finally, we need to enter this code into our footer.php file just before the </body> tag:
Please click here to access the code.
That’s it! You should now be set up to track social media button clicks on your website!
Viewing the reports in Google Analytics
Now that we are passing the social media button clicks into Google Analytics, we need to know where to find it so that we can see the data.
- Login to Google Analytics
- Go into your websites analytics
- In the left menu, click Traffic Sources > Social > Plug-ins
This page will tell you the pages that create the most button clicks, you can go into each page individually to find out which buttons they are, or you could click ‘Social Source’ or ‘Social Source and Action’ to view an overview of all the button presses within your selected period.

Now you can view which buttons your readers are clicking just by going to the Google Analytics Social Plug-ins page.
I hope you find this information useful, I would love to know how you got on with implementing this code, so drop me a comment below.
Send to Kindle