Author image
Senior Mind

Adding the new google plus one (+1) button to your Drupal site

I am sure someone will roll a module very soon, but in the meantime I thought I would blog about our first experiences in adding the plus one button ...

There is plenty of background on the google plusone button already -

It sounds very simple, and indeed it is - with only one small gotcha that we couldn't find any documentation for. We basically followed the steps outlined here : which is simply :

  1. Include the google plusone javascript file somewhere on your page - recommended in the footer.

<script type="text/javascript" src=""></script>

  1. Work out the layout of your plusone button, there are a couple of options - all with varying degrees of "in your face"ness. You can do this here

  2. Add a special tag in the location where you would like your plusone button to appear - there are HTML4 and HTML5 versions of this available, if in doubt go with the HTML4 one. Your tag will look something like this

<g:plusone count="false"></g:plusone>

And that's it ... well at least that should be it - however we just couldn't get this configuration to work, we consistently got a red exclamation mark after clicking the plusone button. After a bit of experimenting we figured out that the URL of the current page needs to be "forced" into the plusone tag in an href attribute - giving something like

<g:plusone href="" count="false"></g:plusone>

Obviously you aren't going to hardcode this URL - but instead populate the href attribute using a smidge of PHP - something like

<g:plusone href="<?php print url($_GET['q'],array('absolute'=>true));?>" count="false"></g:plusone>

And that should do it ... don't forget you need a google profile to use plus one ...


I +1'ed this page :)

Need to try and implement it myself now, but looks like Mike has already done that for us. Computerminds should just add the module ;)

Nice +one

Well, they wouldn't want to make it too easy would they? Nice work!

I think that for D7 you can/should now use the current_path function not $_GET['q']

I'm using the variant code: <div class="g-plusone"></div> for compatibility with XHTML W3c Standard but counter still remain at zero (considering I should have 10 point).

I have no href in my script but all my page have a canonical Tag (so google should be able to interact with).

Someone has idead about?

Indeed, it should work with the canonical tag - but it looks like it may be having some teething problems as we couldn't get it to work without explicitly setting the href in the tag ... obviously not ideal if your looking to keep valid XHTML ...

Comments on this article are now closed, if you want to give us feeback you can use our contact form instead.