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:
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 ) {

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 = + “ (” + + “)”;
      pageTracker._trackEvent(’twitter_web_intents’, intent_event.type, label);
  }’follow’, followIntentToAnalytics);

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.

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

Get blog posts via email


  1. Very good information. Collecting this data is another great way to measure the success of a social media campaign. Since these are such important ranking factors now... these should absolutely be measured and reported.

    reply >
  2. Ben

    Really useful blog, thanks. Only thing I wonder is how much people actually use these tools. And also whether it's better to include loads of options or just go for a few (Twitter, Facebook and now perhaps Google). Are there any statistics on how much people use these links, or which are the most popular?

    reply >
  3. Tom

    Love both these new tools and it's great to see the ability to track them more closely too. Too often social media outlets escape from any close monitoring and precise data so being able to track how much these are used and where best on the page to place them will be great information to have.

    reply >
  4. Hi Rob, good quick coverage of Google's +1. Do you think it is possible to integrate +1 in a tweet or some other external page. for example if you made a picture or video and shared it would there be a way to include the +1 option in that content vs having to go back to the original site?

    reply >
    • Rob Ousbey

      Hi David,

      You can specify the URL to share within the +1 button, so if you're posting a picture on a 3rd party site, you could also include a +1 button with it that points to the original source.

      This just depends on the external site allowing you to post HTML and Javascript to their pages.

  5. [...] Social Analytics: Recording +1 and Twitter button usage in Google Analytics | | distilled [...]

    reply >
  6. Rob

    Interesting post, especially about the Twitter Web Intents events.

    But isn't it correct that GA’s Terms of Service states that you are not to record any personally identifiable information in your Google Analytics data, and so that means you should not record Twitter usernames. So where you say "...and will also record the name of the user that followed you", as great as this would be this shouldn't be done in any case.

    reply >
  7. Rob

    Or in fact does the '' value actually record the Twitter user name of the button you're clicking? Not the user name of the person who clicked it?

    reply >
  8. Rob Ousbey

    Hi Rob.

    I'd asked the GA team about it when I wrote this post - and they said that a site username was fine.

    However, that was a fair while ago, and they may be stricter about enforcing that now.

    You could always play it safe and just record data.user_id (much less 'identifiable') and do the id-to-screen_name lookup later on. That said, Twitter are still promoting recording the screen_name on their intents page that I linked to - and GA haven't called them out on it.

    I'll do what I can to confirm what is considered a legitimate use of custom variables, and mention it in a post if we get clarification.

    reply >
  9. Rob

    Hi Rob, thanks for getting back to me. I did think it strange that Twitter offered such variables if it was going to be a problem with such a major analytics provider. Thanks for clarifying this.

    reply >
  10. Rob

    Hi, as a final note on the whole, "...and will also record the name of the user that followed you." thing when using Twitter's Web Intents when users click a Twitter follow button.

    It does seem like that is not actually the case. I used the below label variable and tested the output.

    var label=intent_event.region+" ("" - "")";

    It registers the ID (and username) of the button that is clicked. Not of the user that clicked the button.

    See this screenshot -

    reply >
  11. Wonder how the two would fare now that it's 2013, Google + has made rapid inroads in social networking, but Twitter's popularity is only going to increase it's pretty much taken over Facebook in terms of engaging with current news and events.

    reply >

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>