// Copyright 2011 Google Inc. All Rights Reserved./** * @fileoverview A simple script to automatically track Facebook and Twitter * buttons using Google Analytics social tracking feature. * @author api.nickm@google.com (Nick Mihailovski) *//** * Namespace. * @type {Object}. */var _ga = _ga || {};/** * Ensure global _gaq Google Analytics queue has been initialized. * @type {Array} */var _gaq = _gaq || [];/** * Helper method to track social features. This assumes all the social * scripts / apis are loaded synchronously. If they are loaded async, * you might need to add the nextwork specific tracking call to the * a callback once the network's script has loaded. * @param {string} opt_pageUrl An optional URL to associate the social *     tracking with a particular page. * @param {string} opt_trackerName An optional name for the tracker object. */_ga.trackSocial = function(opt_pageUrl, opt_trackerName) {  _ga.trackFacebook(opt_pageUrl, opt_trackerName);};/** * Tracks Facebook likes, unlikes and sends by suscribing to the Facebook * JSAPI event model. Note: This will not track facebook buttons using the * iFrame method. * @param {string} opt_pageUrl An optional URL to associate the social *     tracking with a particular page. * @param {string} opt_trackerName An optional name for the tracker object. */_ga.trackFacebook = function(opt_pageUrl, opt_trackerName) {  var trackerName = _ga.buildTrackerName_(opt_trackerName);  try {    if (FB && FB.Event && FB.Event.subscribe) {      FB.Event.subscribe('edge.create', function(targetUrl) {        _gaq.push([trackerName + '_trackSocial', 'facebook', 'like',            targetUrl, opt_pageUrl]);      });      FB.Event.subscribe('edge.remove', function(targetUrl) {        _gaq.push([trackerName + '_trackSocial', 'facebook', 'unlike',            targetUrl, opt_pageUrl]);      });      FB.Event.subscribe('message.send', function(targetUrl) {        _gaq.push([trackerName + '_trackSocial', 'facebook', 'send',            targetUrl, opt_pageUrl]);      });    }  } catch (e) {}};/** * Returns the normalized tracker name configuration parameter. * @param {string} opt_trackerName An optional name for the tracker object. * @return {string} If opt_trackerName is set, then the value appended with *     a . Otherwise an empty string. * @private */_ga.buildTrackerName_ = function(opt_trackerName) {  return opt_trackerName ? opt_trackerName + '.' : '';};
