Social Analytics: Recording +1 and Twitter button usage in Google Analytics

In the last two days, two giants of the web have released new embeddable features for websites.

 

Google +1

The first is Google +1, a feature to let users share pages they like. You can read Google’s information about +1 for users, and their info for webmasters about how to add the button to your pages. Personally, I think this is a hugely important step for Google: the majority of web users can’t show their appreciation for a page in any way that helps Google, since they have no way to link to it from elsewhere on the web. With the inclusion of +1 data into their ranking algorithms, Google is giving every web user a way to communicate their preferences and help influence the search results.

I can see this button having huge adoption amongst savvy website owners; the opportunity of having your biggest fans help to +1 your site is too attractive an opportunity to miss out on, even if it’s only a minor ranking signal.

Users with a Google account can +1 my post with the button below. (NB: don’t worry, no one can see the sites you’ve +1’ed until you opt in to showing this on your Google profile.)

(⇐ This is a real life, working button!)

 

Twitter Web Intents

The second interesting new features are Web Intents from Twitter. This is the umbrella term for a new service that let Twitter users follow, tweet or retweet an account directly from a third-party site. For example, you can follow our accounts or tweet a message using the buttons below. Go on - give them a go now! ;)

These buttons allow you to pop up a user’s profile, in order to follow us.

This crafty link lets you pop up a window to retweet a tweet:

@RobOusbey: Record +1 and Twitter button usage in Google Analytics: dis.tl/k2XizV
Retweet This

 

Analyzing This

It’s great to have people following, retweeting and +1’ing you, but it’s even better when you can analyze the types of visitor that are engaging with you in these ways. By recording this in your analytics package, you can start to look for certain patterns and information: what sources of visitors are more likely to follow your Twitter account, what types of pages are most likely to be +1’ed?

The biggest opportunity is to begin optimizing your site for follows, +1’s, etc. Imagine the power of hooking Google Website Optimizer in here: it could try placing the +1 button in different positions on the page and in different formats, to find out what gets clicked most often.

[Warning, this is where it all gets a little bit geeky.] Fortunately, both Twitter Web Intents and Google +1 offer Javascript ‘callbacks’. This means that after any of the buttons are pressed, you have option to run a specific function. For our purposes (using Google Analytics) we want the callbacks to call a function that calls ‘_trackevent’, with appropriate parameters to record what kind of button was pressed (eg: +1 / Follow / Tweet) and what the action was (eg: +1’ed, un-+1’ed, tweeted, etc.)

Yoast beat me to sharing the code for tracking a +1 click. Via his implementation, recording this in Google Analytics is as simple as adding this button code:

<g:plusone size=“tall” callback=“plusone_vote”></g:plusone>

followed by including this script somewhere on the page:

<script type=“text/javascript”>

  function plusone_vote( obj ) {
    _gaq.push([’_trackEvent’,’plusone’,obj.state]);
  }
</script>

Twitter have already released suggested code for recording Intent events in your Analytics. For example, the code below will record clicks on your follow button - and will also record the name of the user that followed you.

<script type=“text/javascript”>

  function followIntentToAnalytics(intent_event) {
    if (intent_event) {
      var label = intent_event.data.user_id + “ (” + intent_event.data.screen_name + “)”;
      pageTracker._trackEvent(’twitter_web_intents’, intent_event.type, label);
    };
  }

  twttr.events.bind(’follow’, followIntentToAnalytics);
</script>

The code for all of the Intent actions are available in Twitter’s Dev documents (see the bottom of that page.)

There are loads of opportunities here: I’m going to try to collect plenty of data from this page and elsewhere to test the analysis and processing of the data. Of course - there’s nothing to test until you’ve collected some data, so I’d suggest trying to include some of these buttons on appropriate pages soon.

About the author
Rob Ousbey

Rob Ousbey

Rob joined Distilled’s London office in 2008 as an SEO Consultant. Over the years, he’s developed and executed SEO strategy for clients from small businesses to large organizations, and managed Distilled’s Reputation Management projects, where he’s...   read more