specify custom url to gplus one button
Asked Answered
J

1

0

I have this code

<div class="google_button">
   <g:plusone size="medium" annotation="none"></g:plusone>
   <% case I18n.locale.to_s %>
   <% when 'en' %>
    <script type="text/javascript">
      (function() {
       var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
       po.src = 'https://apis.google.com/js/plusone.js';
       var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>
    <% when 'es'%>
     <script type="text/javascript">
      window.___gcfg = {lang: 'es'};
      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
     </script>
   <% end %>
  </div>

I have in a variable url a url:

url = "http://www.mydomain.com/my_custom_url"

I want add to this google plus button this url variable.

How can I do it?

Thank you very much!

Jurgen answered 8/11, 2012 at 21:9 Comment(1)
google_plus_button + url = true; ???Mickimickie
G
1

I managed to find the developer docs. It's a little confusing, but you just need to put the URL as the href attribute of the <g:plusone> tag. For instance:

<g:plusone size="medium" annotation="none" href="the url!"></g:plusone>
Glutamate answered 8/11, 2012 at 21:23 Comment(1)
This is correct; however, the best method is to set canonical URLs for the page. This has benefits for Google Search optimization also in addition to setting the +1 URL. This help topic describes canonicalization: support.google.com/webmasters/bin/…Cayuse

© 2022 - 2024 — McMap. All rights reserved.