Pages

Friday, 28 February 2014

How to add Google +1 to Your tumblr Theme

You can easily add a Google +1 button to your Tumblr theme, all you have to do is to follow the next steps:

  • Go to Google’s +1 Button page and use the customisation panel to style your +1 button.

  • Once you’re done, copy the second part of the code located on the right, which looks like this:

    <!-- Place this tag after the last +1 button tag. -->
    <script type="text/javascript">
    (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/platform.js';
        var s = document.getElementsByTagName('script')[0];             s.parentNode.insertBefore(po, s);
    })();
    </script> 
    

    You should place this code snippet just before the </body> tag.

To add a +1 button for your entire blog:

Copy the first part of the code snippet, add data-url=“{BlogURL}” and add it to your blog.

<div class="g-plusone" data-size="medium" data-url="{BlogURL}"></div>

To add a +1 button to every post:

Copy the first part of the code snippet, add data-url=“{Permalink}” and add it to your blog between each {block:…} … {/block:…} section.

{block:Text} 
    <div class="g-plusone" data-size="medium" data-href="{Permalink}" data-annotation="none"></div>
{/block:Text}