Our blog.

Tracking Google +1 in Google Analytics

Profile Image Posted

Paul Martin

Director of SEO (Australia)

Earlier this month, Google launched the next phase of its +1 buttons, allowing you to embed +1 buttons on your own websites. These +1 buttons look and act similar to Twitter and Facebook buttons do currently, but it is yet to be seen if the Google +1 button will be as wildly adopted. However if you do wish to use the +1 button on your website, it is handy to be able to track how users interact with it in Google Analytics.

Step 1: Creating the Google +1 button

You first need to create a Google +1 button: http://www.google.com/webmasters/+1/button/index.html Here you can complete the basics that include choosing a button size and what language the button should use.

Step 2: Generating the Google Analytics callback

Once you have done the basics, you now need to click on ‘Advanced options’ that will reveal some new fields. One of these advanced fields is called ‘JS Callback function.’ This field should be filled in with a unique term such as ‘plusone_vote’ as shown in the image below.

Step 3: The Google +1 code

Once completed you will then be given the code to use on your website to embed the Google +1 button. The code, to be placed either in the <head> of your site or just before the closing <body> tag, should look something like this:

<script type="text/javascript" src="http://apis.google.com/js/plusone.js"> {lang: 'en-GB'} </script>

And the code to be placed wherever you want a Google +1 button to appear should look like this:

<g:plusone callback="plusone_vote"></g:plusone>

Step 4: Google Analytics tracking code for the +1 button

To tell Google Analytics to track the activity of the +1 button, the following event tracking code needs to be added:

<script type="text/javascript"> function plusone_vote( obj ) { _gaq.push(['_trackEvent','plusone',obj.state]); } </script>

This code can be included with the previous generated code to be placed either in the <head> of your site or just before the closing <body> tag. Once all of the above code has been placed on your website correctly, you will then be able to track how users interact with your +1 buttons as unique events within Google Analytics. Any comments or questions are welcome either on here or Twitter. Catch me at @PG_Martin.