How to Make a Custom Google+ Share Button

Every social network has a url which allows you to easily share your site. Facebook’s sharer.php and Twitter’s ?status= are the most common examples. Google plus has one as well:

https://plus.google.com/share?url=https://mywebsiteurl.com

Using that url you can easily make a quick share popup with just a few lines of javascript:

function GPlusShare(pUrl){
// Set up the window attrubutes
var attributes = "toolbar=0,location=0,height=450,width=550";
// Format the share url
var url = "https://plus.google.com/share?url="+escape(pUrl);
// Open the window
window.open(url,'',attributes);
}

This function can be called from anything that can access the javascript, including Flash. In this example, I used the red g+ button image:

The Google+ share uses facebook’s open graph meta-tags to derive the title, description, and image. Add these to the page you’re sharing to further customize the post. You can view the button in its own page to see the source, as well as some extra code to center the window on screen.

Share on LinkedInTweet about this on TwitterShare on FacebookShare on Google+

2 thoughts on “How to Make a Custom Google+ Share Button

Leave a Reply

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