June 8th, 2010 → 6:50 am
by Robert Kingston
// No Comments
Update 08/08/2010: Improved the link handling & now tracks the post URL in Analytics.
Reading SEOmoz’s blog on the way home from work, I noticed a great little call to action at the bottom of their post that read:
“Did you like this post? Yes / No“
I like this idea of tracking visitor sentiment towards posts, but I think SEOmoz’s version isn’t quite as actionable as it could be. I mean, sure you can see whether or not people liked the blog post from the blog itself, but what if you wanted to delve a little deeper? What if you want to see post ratings aggregated and filtered based on geography, visitor type, conversions, traffic sources, custom variables etc? That could be REALLY powerful – you could find out which posts work for which countries, which posts your visitors didn’t like – so you could improve on it – and so much more actionable stuff like that.
Here’s a way for you to start tracking post ratings within Google Analytics – as if it’s your own little marketing dashboard. To top it off, it’s incredibly easy to implement…
If you have the Asynchronous tracking code (_gaq.push) use this code:
<strong><p>Did You like this post? <span id="ga-like-post">
<a href="javascript:void(0)" onclick="_gaq.push(['pageTracker._trackEvent','Post Liked?','Yes', document.location.pathname ,1]);gaLikeHide();">Yes</a>
/
<a href="javascript:void(0)" onclick="_gaq.push(['pageTracker._trackEvent','Post Liked?','No', document.location.pathname ,0]);gaLikeHide();">No</a>
</span></p></strong>
<script type="text/javascript">
function gaLikeHide() {
_gaq.push(['pageTracker._trackPageview','/tracking/post-like']);
document.getElementById('ga-like-post').innerHTML = '<st'+'rong>Thanks...<'+'/strong>';
}
</script>
If you have the older tracking code (pageTracker) use this code:
<p>Did You like this post? <span id="ga-like-post"><a href="javascript:void(0)" onclick="pageTracker._trackEvent('Post Liked?','Yes', document.location.pathname ,1);gaLikeHide();">Yes</a> / <a href="javascript:void(0)" onclick="pageTracker._trackEvent('Post Liked?','No', document.location.pathname ,0);gaLikeHide();">No</a></span></p>
<script type="text/javascript">
function gaLikeHide() {
pageTracker._trackPageview('/tracking/post-like');
document.getElementById('ga-like-post').innerHTML = '<strong>Thanks...</strong>';
}
</script>
That’ll do it. So now you’ll be able to find out whether you’re writing useful articles or whether you’re sourcing a whole load of grumpy traffic – (Yeah, that’ll be it. Your writing is awesome…).
Show it to your friends:
Tweet