Add a Google+1 Badge to Your Website

By  on  
Google+ Badge

Google's new Google+ service is taking the development world by storm, and why shouldn't it?  It's minimalistic UI, use of cutting edge web techniques, and overall usability make it Google+ one of the more impressive web applications I've seen in quite a while (I was going to say "since Google Wave", but that one didn't end up well, did it?) Google+ allows you to share photos, links, statuses, and much more;  consider it a mesh between Twitter and Facebook.

Google+ will only gain more traction, meaning that the information we share will be pushed to more and more people.  This presents an excellent opportunity to promote our websites, much in the way that Twitter and Facebook have.  Let me show you a few different ways to add the new Google+1 badge to your website.

The Simple HTML

Adding a Google+1 badge is as easy as adding a few HTML tags:

<!-- one button, uses canonical link or current URL -->

<!-- customized for a specific address -->
<g:plusone href=""></g:plusone>

<!-- include the JS file -->
<script src=""></script>

Provide the g:plusone tag the URL to share via the HREF attribute (if none is provided, the page's canonical link will be searched for and used, otherwise the current URL is used) and the desired size of button via the size attribute.  This tag should be added wherever within the page that you'd like the button to appear;  the SCRIPT tag should be found at the bottom of the page.  If you'd prefer not to dabble with the HTML yourself, Google provides a Google+1 button builder to do the dirty work for you.  Four button sizes are currently offered.

You could also use the following HTML5 code to render your button:

<div class="g-plusone" data-size="standard" data-count="true"></div>

Your button must have the g-plusone CSS class and data- attributes for options.

Deferring Loading

The HTML code above will render with the rest of the page, but what if you want to render a button on your own schedule?  No worries -- Google's API allows you to render buttons whenever you'd like:

<!-- one button, uses canonical link or current URL -->

<!-- Place this tag in your head or just before your close body tag -->
<script src="">
  {parsetags: 'explicit'}

<!-- Now render! -->

Using {parsetags: 'explicit'} and gapi.plusone.go() will turn your g:plusone tags into badges whenever you'd like. You can also render a specific button with the following JavaScript code:

<script type="text/javascript" src="">
	{"parsetags": "explicit"}
<script type="text/javascript">
	function renderPlusone() {
	<a href="#" onClick="renderPlusone();">Render the +1 button</a>
	<div id="plusone-div"></div>

Full API information as well as an introductory video is available here.  There are a few more small customization options available so check them out if you're looking to specify language or play with custom rendering.

Don't miss out on another avenue for sharing your awesome web content with everyone!  Implementing Twitter, Facebook, and Google+1 sharing buttons takes 5 minutes but the amount of traffic you can gain via these referral avenues is tremendous!

Recent Features

  • By
    Write Better JavaScript with Promises

    You've probably heard the talk around the water cooler about how promises are the future. All of the cool kids are using them, but you don't see what makes them so special. Can't you just use a callback? What's the big deal? In this article, we'll...

  • By
    5 Awesome New Mozilla Technologies You&#8217;ve Never Heard Of

    My trip to Mozilla Summit 2013 was incredible.  I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out.  MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...

Incredible Demos

  • By
    Sexy Album Art with MooTools or jQuery

    The way that album information displays is usually insanely boring. Music is supposed to be fun and moving, right? Luckily MooTools and jQuery allow us to communicate that creativity on the web. The XHTML A few structure DIVs and the album information. The CSS The CSS...

  • By
    jQuery Link Nudging

    A few weeks back I wrote an article about MooTools Link Nudging, which is essentially a classy, subtle link animation achieved by adding left padding on mouseover and removing it on mouseout. Here's how to do it using jQuery: The jQuery JavaScript It's important to keep...


  1. NIce, thanks :)

  2. Sam

    Awesome, will have to get this on some of my sites then.

    Just a quick one, is there not a valid XHTML way of doing it? I am assuming data-* attributes are not classed as valid xhtml? Especially the namespaced element method.

  3. Chris

    Any idea how i can edit the preview-image and excerpt that is shown in google+? Like the og:image tag in facebook open graph.

    It shows some weird and unrelated images and text from somewhere on the page…

    • Not yet, but I’ll investigate.

    • still trying to solve that too. but did not get any information yet. also, something similar to Facebooks URL Linter would be nice during development. I will post solution here on success.

    • Any update on whether og:image or image_src works for Google Plus? I’m currently pulling out what little hair I have left trying to figure this out.

      I’m also wondering whether Google Plus has a URL/link cache that needs clearing.

    • Sasa

      Try passing page url like this:

      gapi.plusone.render(‘element’, {‘href’: ‘’);

    • Did any one find how to over ride unrelated images from page with single image

    • ramya

      Did any one find how to avoid unrelated images from page

  4. Makash

    Yeah awfull !!
    Can I have a g+ invitation please ? ;)

  5. Thank you for this simple explanation.

  6. Oops, you mean a Google +1 badge, not a Google+ badge, right? Google+ is (or will be) about 8 different and bigger things than just the +1 button, but only the +1 button is currently publicly available to site developers.

  7. We used this excellent plugin Plus 1 by Steven Gray for our site eMirror – the world’s only online mirror.

  8. Thanks mate, your a good egg :)

    Google should really over thought long and hard about profile buttons before launching G+ – i’m rather worried.

  9. Alex

    Thanks David
    One question though what if you needed multiple buttons in one page, for example in a list.
    Is it simply the case of providing different href per button?

  10. Thx for this article, however that’s a pity +1 integration breaks W3C code validity, so I wouldn’t put it on my website ^^

  11. Thanks you for the instructions. Our clients are sure to be asking for this soon, and now I am prepared!

  12. Sven

    Thanks David Walsh.

    Do you know if it is possible to add a Google +1 button with pure html (no javascript)?

  13. Carsten Milkau

    Text is invalid HTML (because only either src oder Text is allowed) and causes a JS error in FF7, as it tries to parse {parseTags: … } as normal JavaScript, which is doomed to fail.
    Maybe you can find a cleaner way to do this, like
    gplusone_options = {…}

    That’d be great!

  14. Carsten Milkau

    is invalid HTML (because only either src oder Text is allowed) and causes a JS error in FF7, as it tries to parse {parseTags: … } as normal JavaScript, which is doomed to fail. Maybe you can find a cleaner way to do this, like
    gplusone_options = {...};

    That’d be great!

  15. Carsten Milkau

    Waah, wrapped in code-Tags and still stripped -.- Last attempt with entities:

    Causing JS Error:

    <script src="...gplusone..."> Text </script>

    Suggested improvement:

    <script src="..."> gplusone_options = {...}; </script>
    <script src="...gplusone..."></script>
  16. Thanks for this, I put a G+ Plus 1 Button on my webcam page. :)

  17. Hi Thanks for the post.
    I added google plus badge to my blog, it works on PCs and laptops..
    when i view my site in mobiles, G+ badge and plus one button are not shown..
    may i know the reason why its not shown?
    I love G+ because it increases your chances to show on top in search engine

  18. Can you tell me how to change we’re word with site name in google plus badge

  19. i wanna put it on floating bar… is it possible

  20. Hello,
    see i’m bit new to this. i have a question, in Webmaster Tools you get different button that to normal +1 button are they both different?

  21. can you plz tell me what is the advantages of google+ button
    and the diffrence of badge and button??

  22. Google+ badge, right? Google+ is (or will be) about 8 different and bigger things than just the +1 button, but only the +1 button is currently publicly available to site developers.Maybe you can find a cleaner way to do this, like
    gplusone_options = {…}

  23. Seems alittle bit complicated just to add the g+1 button to my website. Can’t you get this code from Google’s website?

  24. Very useful script.. i will definitely use one of theses!

  25. Hello,
    I have a static website and i copy pasted this code in the source but its not showing anything on the page.
    i have no programming knowledge so i don’t know what i am doing.

  26. Thank you it works great on my website.

  27. Hi,

    Any one any idea how to get a Google Plus Side Follow Widget which is Vertical in nature and when hover pops a little and then customer can share the site.

    Thanks & regards

  28. The latest badges for Google plus are really nice and fit snuggly in the sidebar.

  29. The code is not visible under mobile devices. Tried with latest Android and iOS version. Any help would be appreciated.


Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!