How do I track social engagement in an A/B testing using Google Analytics?

392 Views Asked by At

I am using Google Website Optimizer to run an A/B test. There are several conversions I am tracking:

  1. Making a purchase.
  2. Liking on Facebook.
  3. Following on Twitter.

The first conversion is easy to track. I simply have a page on my web site that says "Thank you for your purchase" and use that URL as the conversion URL.

The other two items are a little confusing to me.

Let's just use the Facebook example, as what I can learn from that I can apply to Twitter and any other social network as well. According to Facebook [1] I can use the following code to track someone liking a page:

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

That will, I believe, help me track "social engagement." However, I need this to be associated with the specific A/B test the user happens to be using at the time.

Now Google also shows me how to track link clicks as conversions in an A/B test [2]. This looks like it would be helpful:

<!-- Google Website Optimizer Tracking Script --> 
<script type="text/javascript"> 
var _gaq = _gaq || []; 
_gaq.push(['gwo._setAccount', 'UA-XXXXXXXX-X']); 
function doGoal(that) { 
 try { 
  _gaq.push(['gwo._trackPageview', '/YYYYYYYYY/goal']); 
  setTimeout('document.location = "' + that.href + '"', 100) 
 } 
 catch(err){} 
}
// SNIP 
</script> 
<!-- End of Google Website Optimizer Tracking Script -->

Now, I have taken this code to make this, which hooks into the event triggered when a user clicks the like button. First, in my Google Analytics initialization code:

// Additional initialization code here
FB.Event.subscribe('edge.create', function(href, widget) {
  alert('You just liked the page!');
  trackFBLike();
  return false;
});

Then this on my page specific Web Site Optimizer code:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['gwo._setAccount', 'UA-XXXXXXXXXX-2']);
function trackFBLike(that) { 
  try { 
    _gaq.push(['gwo._trackSocial', '/YYYYYYYYYY/like']); 
  } 
  catch(err){} 
}
// SNIP 
</script>
<!-- End of Google Website Optimizer Tracking Script -->

So my question is this:

Am I on the right track? Have I missed any steps? Do I need to setup Goals as well within Google Analytics? Help?

1

There are 1 best solutions below

0
On

Looks like you're pretty close. I don't think this will work though:

_gaq.push(['gwo._trackSocial', '/YYYYYYYYYY/like']); 

gwo, as far as I know, only supports trackPageview, and only URLs of a particular pattern; you can't mess with the URL that it sends.

_gaq.push(['gwo._trackPagview', '/YYYYYYYYYY/goal']);

(Which means, among other things, you can't easily have multiple goals and be able to differentiate among them, though there are complex work-arounds).