Trouble Setting Up The Google Plus One Tag?
A Little Experiment - Google Plus One Not Working And How I Fixed It
This post is a little experiment.. rather than being an article pertaining directly to dating, it’s more about a technical component of the site: The Google Plus One button, and my issues with it not working. If this article is well received, I may very well post more of these.
Google Plus One
So, the other day I found out about the new Google Plus one feature. It’s a social feature, similar to Facebook “Like,” that allows website visitors to cast their vote for that site and tell Google how much they love it. It’s not used by any Google algorithms to influence the search results (yet), but the plan is to have the plus one votes listed beside the site in the search results. Apparently, if any of your friends on your Google profile have given a site the Plus One, you may be notified.
Down to the nitty gritty: I went to the Google Plus One homepage for webmasters, which allows you to create a button to add the “Plus 1″ button to your site. Filling out their form gives you something like this:
<!-- Place this tag in your head or just before your close body tag -->
<script type=”text/javascript” src=”http://apis.google.com/js/plusone.js”></script>
<!– Place this tag where you want the +1 button to render –>
<g:plusone></g:plusone>
I happily added the script tag to my header, and the <g:plusone> to a nested div just above CupidMarket’s main login box, then ran the build locally. What? It didn’t show up. The tag remained as <g:plusone>. Puzzled, I uploaded my changed gsp page to CupidMarket’s servers, and refreshed. Still the button didn’t show up. And when I inspected the source with Firebug, I saw that the html element g:plusone hadn’t been replaced (on a working site, the DOM is updated by Google’s “plusone.js” javascript, replacing it with an iframe containing the clickable button).
I scratched my head for a while, trying different things, and eventually gave up. Having stayed up too late (yet again), I decided I’d take out all the Google Plus One code the next evening.
Discovering An Undocumented Google Plus One Problem
The next evening I decided to give it one more try. I was nesting the <g:plusone> tag deep within the divs of my page body, so on a hunch I supposed that the Google DOM parsing code couldn’t handle it. I decided to try putting it as the first tag in the body. Behold! It worked! The <g:plusone> was replaced with the Plus One button iframe.
I took a look at the Google Plus One Full Documentation and discovered the explicit “parsetags” option, and noticed that with it, you could use the gapi.plusone.go() javascript method to specifically the exact name of the parent div that contains your <g:plusone> tag. So, I nested that tag in a new div, named “plusOneBox”, then called the gapi.plusone.go() javascript method, specifying the class as the argument.
And that code looks something like this:
<div class="plusOneBox">
<g:plusone count=”true” size=”standard” href=”http://www.cupidmarket.com”></g:plusone>
</div>
<script type=”text/javascript”>
gapi.plusone.go(”plusOneBox”);
</script>
Viola. I can now place my Google Plus One button anywhere I want on the page. It’s kind of an undocumented gotcha, since nowhere in the Google docs (as of June 7th, 2011) is it mentioned that the default button won’t work if you nest it within too many divs.
Summary
I hope you enjoyed this little experiment into the technical side of this site. If you enjoyed it, +1 the page. And if the Google Plus One Button is not working for you, follow the above steps to remedy your problem!
Related Articles
Responses to "Trouble Setting Up The Google Plus One Tag?"
Leave A Reply
June 7, 2011
Your plus one button doesn’t show up on Firefox 3.5!
June 7, 2011
pluson button doesn’t show up in firefox 3.5!
June 7, 2011
Kal,
Yeah, Firefox 3.5 is unsupported by Google. Check:
Supported Browsers
That said, I could probably tweak it to work, by using the Explicit Render option, instead of the custom javascript tag, as documented on http://code.google.com/apis/+1button/.
June 7, 2011
While the plus one button shows up, in the page XHTML 1.0 Transitional! validation it shows up as 2 errors
there is no attribute “size”
and
element “g:plusone” undefined
you too have additional validation errors HERE on THIS page.
may be Google should learn to offer w3c compliant gadgets like addthis and others can do.
I have no intention to screw up my valid pages across my site and have removed the pluls one for now until Google offers something valid.
June 7, 2011
yes, unfortunately custom javascript tags aren’t included in the current W3C spec.. you’ll also notice that the <fb:like> tag for the Facebook Like button at the top of the page is failing HTML checks too. While the results are too early to call, registrations are up slightly today, so I’ll be leaving the Google plus one active..
W3C compliance isn’t a big big worry of mine, as I doubt Google would penalize sites for using its own button. That said, there are other search engines to keep in mind, and I’ll watch my ranks on bing/yahoo
June 10, 2011
I agree that Google isn’t going to penalize you, but it and some other non-compliant code I use annoys me because rather than just looking for a successful validation, I have to paw through the errors , saying. Oh yeah, that’s Google, that’s Kerio..”.
It’s annoying.
June 13, 2011
This is a great article. Thank you so much for taking a few minutes to summarize all of this out for all of us. It really is a great guide!
June 13, 2011
I took the example code straight off of google. saved it as gPlusOne.html
Tried it in Firefx 4, chrome and IE. The example code just won’t show the button.
What gives ?
+1 demo: Basic page
June 14, 2011
Try uploading it to a live web server and let me know if that works for you
June 16, 2011
This is the only real answer I found in the net about a possible solution for this f***ing plus one button! All the others play around with changing the order and location of the scripts, hoping that “for some unknown reason” the button may be fixed. I’ll try this, hope it works! Thanks
June 28, 2011
Vince I know, I couldn’t find the answers to what I was looking for either, which is why I wrote this post after I figured it out on my own! Hope it helps you, and if not, feel free to send me a message or post another comment and I’ll try to help.