A Google+ Share With Attribution Button for Any Site
The other day i saw this article on The Next Web about adding a Google+ share icon to your WordPress blog. It is based on the original article from Alex Moss. The main limitation is that it uses the mobile version of Google+ to make it work. Not a big deal just not that pretty.
So I thought this is pretty handy and while WordPress is huge among bloggers, there are still tons of other sites and blogs that might want a sharing button. Then I thought I could take it a step further and include a way to add attribution.
On Google+, you give someone attribution or address someone by putting a + in front of their name. For example +George Washington. Google Plus then turns these into links and notifies the person they have been mentioned in a post. The problem is, if you “+” some one that isn’t in one of your Circles it doesn’t always work. Unless you know the little known secret: you can “+” a user number and it should work everytime. This also ensures your are attributing the right +John Smith! My code below will take advantage of this feature since people outside of your circles could be sharing from your site.
So, how do you get your user number? Just go to Google Plus and click on your profile. Your user number is that big bunch of numbers up in your url
right after plus.google.com.
Below is the code to place anywhere in your site where you want the share button to show up.
Note: If you want to use attribution, replace the numbers after via + with the numbers from YOUR user number. Be sure to leave the “+” there!
If you do NOT want to use attribution, delete everything between the quotes after attrib=. So it should read: attrib=’ ‘
<a href=”javascript:var d=document,w=window,attrib=’ via +123456789012345678901‘,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f=’https://m.google.com/app/plus/x/’,l=d.location,e=encodeURIComponent,u=f+’?content=’+e(d.title)+e(‘ – ‘)+e(l.href)+e(attrib)+’&v=compose&hideloc=1′;a=function(){if(!w.open(u,’gplusshare’,'toolbar=0,resizable=1,scrollbars=1,status=1,width=450,height=295′))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)”><img class="scale-with-grid" src=”http://dl.dropbox.com/u/118970/plus-share.png” width=”55″ height=”22″ alt=”Share this post on Google+” title=”Share this post on Google+”></a>
Here is the same code in a text file that should make it easier to use since these kinds of things with quotation marks can get confused by browsers. share.txt
You shoud be able to use this code on any site that lets you add html. Google may have something else in the works to make this easier. But for now, this should fill the gap.
excelent!
but how I can add images from the web page
thanks
Comment by chris — August 18, 2011 @ 6:05 pm
Unfortunately you can’t. That is the downside to this and there isn’t (currently) a way around it.
Comment by admin — August 18, 2011 @ 11:34 pm
Pret panou radiant…
[...]A Google+ Share With Attribution Button for Any Site[...]…
Trackback by Pret panou radiant — December 27, 2011 @ 12:28 am