Adding the Google +1 button

The +1 button is shorthand for “this is pretty cool” or “you should check this out.”

Click +1 to publicly give something your stamp of approval. Your +1’s can help friends, contacts, and others on the web find the best stuff when they search.

So, I thought why not give it a go. At the moment it’s available only on .com version of Google, which I never use, but I expect it to be rolled out to all google sites soon. So let’s get ready for that.

There appears to be two ways in which a user can +1 a site;

1. Via the google.com search interface

You can see the +1 button. When clicked it turns blue.

2. Via your own site. To enable this we need to add some code to osCommerce. The code can be found at http://www.google.com/webmasters/+1/button/index.html

Simply decide which button you want to show, and copy/paste the code! What could be simpler?

Code Changes

Step 1. Open up /includes/template_top.php and add this line of code just before the </head>

<script type=”text/javascript” src=”http://apis.google.com/js/plusone.js”></script>

Step 2. Open up whichever file you want to add the +1 to. In my case, I chose to put it only on the product pages, hence product_info.php

Notice the extra line of code at line 76? That’s it! Now, the +1 button is active and ready to go.

If you are on an older version of osCommerce you would be changing /includes/header.php rather than includes/template_top.php and placing the +1 button in a table somewhere in product_info – the basis of the change is exactly the same whether you use 2.3.1 or 2.2.

24 Replies to “Adding the Google +1 button”

  1. Isa – I don’t know if it’ll take off…does Google have the social aspect that facebook does do you think?

  2. Gary
    …I don’t know, but they are definitely trying to move into the social space. A while back they were saying article writing was a top priority now they say the priority is social media marketing.
    Given that a lot of people are using facebook and such to drive traffic especially since the panda update, it makes sense for google to come up with the +1 button to compete with the facebook like button.
    I think that most people use google, rather than facebook, to find information, so ultimately this could turn out to be successful.

  3. ***successful at least for those who will start selling “optimized +1 strategies”***

    lol, I hadn’t thought of that, good one George! 🙂

  4. I did consider putting it in the footer, but thought it would be more visible in the product’s page.
    I wondered also about adding it to the left column, beside the facebook, twitter, tell a friend etc. buttons?
    what do you think Gary?

  5. Nick – whether to do just product pages or the whole site is up to the individual shop owner. My opinion is that oscommerce is a shop, shops sell products, so product pages are what I want to encourage people to +1

    Use Canonical URL.

  6. Thanks Gary. I tend to agree with your reasoning here.

    I guess this opens up another can of worms, but what would the proper syntax for the canonical be?

    I have in the of index.php but have no idea what would go in product_info.php, especially since I have Ultimate SEO URLs 5 installed to rewrite everything.

    Or should I just leave the URL section of advanced options blank, and then the button will refer automatically to whatever product page is being visited? Seems like such a simple question, but the instructions for this and even the FB Like button don’t address it!

  7. Hi Isa – extra URLs in posts made on the blog mean they go to me for approval as most spammers tend to have loads of URLs in their posts. Not your fault that the post didn’t immediately show 🙂

  8. The Canonical URL is the URL that you use in your shop, without any extras like session ID.

    Leave the URL section blank to see how it goes, and if it’s not right, then you would need to amend your site head tags to include a —link rel=canonical— tag

  9. Been looking at this today at .webpronews.com/google-1-button-3-2011-06 – some interesting comments about it there as well.

    On of the things I’m finding out about google using their webmaster tools is whenever a page is slow to load it is always a google script that is the slowest to load causing most of the problems. One has to wonder if +1 is going to cause more page load problems than the amount of extra traffic it may produce.

    One other thing is the fact that you have to be signed into google for the +1 to have any effect – so just how many of your prospective customers are likely to be signed into google when they buy on your site – perhaps the same ones that have or, to be more precise, use Sidewiki? – That means no one that accesses this site for a start.

  10. Anyone who uses Google things like gmail, buzz, blogspot etc are usually signed into their google account…

  11. Yeah, the same caveats apply to the FB Like button it seems. You have to be logged into Facebook for it to work. But that button is now ubiquitous…

  12. I have found an issue on IE8 where, when logging into a customer’s account, a message would warn about the page containing both secure and unsecure items.
    I found out it’s the bit of code in includes>template_top.php causing the problem because scripts from an http source will cause a problem on an https page, at least they do on IE.

    After various searches I found this solution: I removed “http” from the code, so in includes>template_top.php I now have:

    This way I believe the link will automatically switch when the browser switches between normal pages and ssl pages.

    It works for me so I thought I’d share.

  13. Hi Gary

    I did notice my code disappearing, I thought it was me not having posted it correctly 🙂
    Anyway my code was exactly like the one you posted but without the “http” or “https”, so the link would start with the double forward slash.
    What you said is interesting, I hadn’t even thought of that solution, thanks for pointing it out, but hey, isn’t IE a complete pain sometimes? 🙁

  14. Interesting link, thanks for posting it 🙂

    I love the way he displays the social media buttons at the bottom of the article, under “share the knowledge”. It would look good in product_info.php, right under the product description.

  15. Thanks for posting this Gary.
    I wonder how many non googlers would figure out what it’s for? I wondered if a customer would change their mind, about reverseing their vote. So I tried a +1 on a shop item and found you can toggle on/off your vote.

  16. I noticed that Google have just added it to your webmasters tools as well so you can see just how many people are not clicking your +1 😀

  17. I’m pretty sure that social interaction can only become much bigger in the future, with Google certainly skewing their search results because of this.

    Imagine the possibility of owning a shop selling widgets in Astoria Oregon. And that a couple of Astoria googlers have +1’d a particualr product of yours. I’m certain that in time, Google will put 2+2 togther and show that result to a geo-ip location search…

    I think adding the +1 can only be considered a positive.

Leave a Reply

Your email address will not be published. Required fields are marked *