1. Get a Facebook Like Button on your page(s)
The first step is to actually get a Facebook Like Button on your page. The quickest way to do this is to go here:
Just fill out the form and click the “Get Code” button…you’ll see something like this pop up:
Now, you’ve got two options here. The iFrame version is admittedly the easiest to install, but unfortunately you don’t have any way to track when someone actually clicks and successfully “likes” your page as a result. There’s no
- Update your
tag to include
- Update your
- Add the proper Open Graph Protocol meta tags – this is not necessarily required but a good thing to do.
- Add the XFBML that you generated above (make sure to update it with your own page URL as the source and add any available attributes you might want) where you’d like your button to appear on your page:
2. Fire a Google Analytics Event when a “Like” action occurs
OK, at this point you’ve got your Like button up and running. Now in order to track these in Google Analytics, we’re going to use Event Tracking to fire an event whenever someone successfully Likes the page. You can choose to set this up in whatever hierarchy you like, but here’s one you might want to use:
Label: URL of the page that was “liked”
_trackEvent() method of the
href contains the URL of the page that’s being “liked”
So the last step in this process is to actually fire this code only when a successful Facebook like occurs. To do this, we’re going to subscribe to an event that Facebook exposes to us when the successful “like” action occurs. When we detect that event, we’ll fire our
_trackEvent code. Here’s the code that will do it:
Note: The safest placement of this code is somewhere BELOW your standard Google Analytics tracking code – this will ensure that the
pageTracker object has been defined before you try to use it
That’s it! Feel free to get creative here…want to use a Custom Variable to create a segment of either visitors (scope = 1) or sessions (scope = 2) that “Liked” something? Then all you would have to do is something like this (make sure your slot 1 is available and you want this at a visitor scope for the exact code below):
3. Find that data in Google Analytics and USE it!
Now, you can log into your Google Analytics account and head over to the Content > Event Tracking reports and take a look at the Categories, Actions and Labels as you’ve defined them:
Note that here we’ve drilled down to the Category of “facebook” and the action of “like” – now we’re looking at a list of the URL’s we passed in – or in our case the actual blog posts that people “liked.” They’re a bit ugly since they’ve been formatted for proper URL encoding, but hovering over the label itself will let you see the URL that was “liked” pretty clearly.
So what do we do with it?
Well, this is one more set of data that can be used to identify what content resonates with your user base. Which are the popular themes of blogs? Which are the authors that our visitors like the best? Which topics do people like to read about? We can look at the Site Usage tab right here to understand if people who like certain blog posts are any more engaged (think bounce rate, time on site, average pageviews per visit) than others. We can look at our Ecommerce tab and find out if people who like certain pages are more or less likely to, say, sign up for one of our Google Analytics trainings. With this knowledge, we can tailor the content that we write to the things that people like the best and the things that get people to engage with our site and convert on our goals.
And don’t forget about your Advanced Segments! Below you can see a quick Advanced Segment configuration that will quickly let you compare those Facebook Likers to any other segment of traffic you care to define:
Hope this helps a few of you out, and we’d love to hear how you’re using this in the comments!