Over a million developers have joined DZone.

Tracking Social Interactions with Google Analytics

DZone's Guide to

Tracking Social Interactions with Google Analytics

· Web Dev Zone
Free Resource

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

I’m spending time this week updating my social sharing buttons, claiming authorship of my blog posts, and linking with my Google profiles.

A big part of this is also to update my Google Analytics to track social interactions with kinlane.com and blog.apievangelist.com.

If you have set up both Google +1 and the latest version of Google Analytics on the same page, all +1 social interactions will be tracked automatically.

To get social interaction tracking and reporting for other networks like Facebook or Twitter, you need to integrate Google Analytics tracking along with each network button.

Using Google Analytics Social Tracking, you can record interactions range from a Facebook “Like” to a Twitter “Tweet.” This allows me to view track on these social interactions along with other traffic to my blogs, in my Google Analytics dashboard.

I added tracking for Facebook recommendations:

FB.Event.subscribe('edge.create', function(targetUrl) {
  _gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);

Also added tracking for Facebook shares:

FB.Event.subscribe('message.send', function(targetUrl) {
  _gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);

Then I added tracking for tweets:

twttr.events.bind('tweet', function(event) {
  if (event) {
    var targetUrl;
    if (event.target && event.target.nodeName == 'IFRAME') {
      targetUrl = extractParamFromUri(event.target.src, 'url');
    _gaq.push(['_trackSocial', 'twitter', 'tweet', targetUrl]);

There were not ready to go scripts for tracking LinkedIn and StumbleUpon. I will be working on these as I can, so that I can track shares from my blogs to these social networking and bookmark sites.

From http://www.kinlane.com/2011/07/tracking-social-interactions-with-google-analytics/

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}