Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Tracking Social Interactions with Google Analytics

DZone's Guide to

Tracking Social Interactions with Google Analytics

· Web Dev Zone ·
Free Resource

Jumpstart your Angular applications with Indigo.Design, a unified platform for visual design, UX prototyping, code generation, and app development.

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/

Take a look at the Indigo.Design sample applications to learn more about how apps are created with design to code software.

Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}