In doing some reading both in Google Webmaster Tools and on blogs across the web, I'm seeing suggestions that adding the Google Plus One functionality to a site (otherwise known as the Google +1 button), can potentially have a very positive impact on Search Engine Optimization. Visitors to your site can use the button to tag pages for themselves privately or to recommend the pages publicly. There is a very simple way to integrate the Google +1 button into a Drupal site. If you are using the PHP filter module for other purposes, then you can create a block and add the Google +1 code within the block, selecting PHP code as the text format. If you are not using the PHP filter module already, then there is no need to turn it on. Instead, you can make the code work through the following steps, as shared by Amye Scavarda from Drupal Gardens:

1) Create a new text format that you'll only use for this, make sure that it's only available for admin, and make sure that every option is unchecked. This means that the HTML won't be purified, no filters will be run on it, etc. This should be used with caution, and only for these particular instances. (Text Formats are under Configuration -> Content Authoring.)
2) Create a new block with this new text format, paste the G+ code in, and figure out where on the page you want this to go under 'Block Location'. I put mine in 'prefooter first'.
You may want to restrict this to certain content types, like just blog pages, or certain pages, or certain roles.
Good luck!

Comments

nevets’s picture

One could also use one of the modules that support Google plus 1.

couturier’s picture

Yes, I looked at the most popular module for this. However, simply using a new text format is so brilliantly easy, simple and lightweight, why add a module? Every module you add and enable slows down your site. Simply creating and selecting a new text format is effective and uses core functionality that is maintained by core updates. It takes less than five minutes to add your Google +1 button this way, much faster than a new module installation.

chike’s picture

Thanks couturier you saved me a lot of headache. I had created a block on which I had a Tweet button, a Facebook like button and a Google plus button all lined up in one div tag. The first two had displayed with Full HTML text format but the Google plus button wasn't showing.

I had thought of what to do until I found your post and I only switched text format to PHP code and the three displayed.

Thanks a lot!

couturier’s picture

That's an interesting application. In fact, I just went to my site and tried it, putting other items besides the Google Plus One button in with the PHP code text format. For my particular site, it did not work well, because it messed up spacing between other items. I even tried putting a manual <br> between the items for each line, but they were squashed together with the PHP code text format.

What I'm doing is putting the Google Plus One button in a block all by itself, so the PHP code text format is applied only to that. Glad the hints helped you.