Adding a Google+ Badge to your WordPress Site

Google Badge

One part of a business social media strategy is to find ways to link your social activity to and from your website. Google+ has some great badge tools with many options for customization. We won’t get into a lot of those options here, but will focus on the “quick and dirty” steps needed to get a badge on your WordPress site.

You can place badges for your profile, page or community. Most businesses have either a profile, or a page attached to a profile. If you happen to also have a community you are sponsoring or are monitoring, a badge linking to that community would also be a plus. Currently there is a plugin that places a badge widget in your widget collection. Some have had good results, some have had problems. Following is the “manual” way, which also allows for a lot of customization.

So Let’s Get Started….

Step One – Go to the Google Developer Badge Page

Google has an excellent page that has everything you didn’t want to know about placing and customizing badges. We will start here and try and guide you to the essentials. Start by going to:

The first thing you will see is the Badge wizard. This is where we can do most of our work and then later we’ll explore a few custom options that might be useful.

 Google Badge Wizard

 There are different options depending on whether you select portrait or landscape, and they change dynamically when you make those selections. The first step in this wizard it to select the User, Page or Community. The default is User and the dropdown will also have any pages that are part of that users profile.  If you don’t see what you need, select “Other” and then you can insert the URL for that page, profile or community.

 Google Badge User OptionBasically go to your page, profile or community and copy the URL, only include up to the big long hairy number (unless you have a custom URL then use that instead.) leaving out the “about” or “post” part.

Google Badge User ID

After you select the user or enter the URL for your page or community then you will see the example showup on the right preview. Play around with settings a bit so that you can see the options.

Step Two – Deciding where you want your Badge

Before we finalize which badge style will be best, you first need to decide where it is going. On your WordPress site there are “widget areas”.  Where and how many of these areas depends on your theme. Bring up your site and using the information you gathered in Step One, decide which type and size of badge will work best.

Next log into your site admin and go to “Appearance|Widgets”. On the right you will generally see a collection of widget areas that are available on this theme. Open a widget area that seems to be located where you think will be the best.

Google Badge Widget Area

Above is an example of a widget area that in this theme is called the Primary Widget Area. In this area we need to drag a “Text” widget and then click the down arrow to expand it:

Google Badge Widget Text

In the example above I have already pasted the code, but we are going to talk about that in more detail next.

Step Three – Get the Code

 Now we have all of the pieces:

  1. Decided on the type of badge or badges you are interested in using
  2. Reviewed your website and decided where you might want to put your badge or badges
  3. Logged in and found the Widget Area that will place your badge in the right place.
  4. Placed a Text widget into the Widget Area.

Back at the Google+ badge wizard make any adjustments you need to do so that it will fit into the selected Widget Area.  Once you get that finalized, scroll down and and copy the code. It will look like:

<!-- Place this tag where you want the widget to render. -->
<div data-href="//"

<!-- Place this tag after the last widget tag. -->
<script type="text/javascript">
  (function() {
    var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
    po.src = '';
    var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);

 If you want to place a smaller bit of code that is HTML5  compatible you can scroll down further on the Google+ Badge page you will see code like this:

<script type="text/javascript" 
<div class="g-person" data-href="{profileId}"

Make sure you replace the {profileId} with either your ID or your Custom Url ID. 

Next take you copied code and paste it into the text area:

Google Badge Widget Text

Do NOT put a title for the Text area, leave that blank.  Click save.

Step Five – Preview and Adjustments

Once you have saved your text you can now go and preview your handy work.

Google Badge Sidebar Example

The above example shows the placement of two small landscape badges for pages. These were placed in the right sidebar of the site. Note that the “script” part of the code only has to be on ONE of the badges. You can leave it off any other badges you place on that page. Therefore your second badge would only look like

<div data-href="{profileId}"

..without the script block.

If you are happy with the results you are done!

Tweaking your Badge – Advanced

You can get really fancy with customizing your badge, but we will not be going into it that deep here. There are a couple of areas you can do some quick and simple adjustment after you have pasted the code.

Badge Width

Use the attribute “data-width” to adjust the width of your badge. Note that each type of badge (portrait or landscape) had  very specific width ranges.

Portrait layout
180-450 pixels
Landscape layout
273-450 pixels

You need to keep this in mind when you make adjustments to your badge as the code will ignore any number outside these ranges.  Your code would look like this:

<div data-href="{profileId}"

(Note that I have left off any other settings that might also be used in the above example.)

There are a number of other settings provided that will over-ride the defaults. These are found on the developer page, they are:

  • Show Cover Photo – control when to show the cover photo
  • Show Tag Line
  • Color Theme – light or dark
  • Community – Show Owners

So… Get your badge or badges on your website or blog and make that two way connection between your social engagement and profile and your website.  If you need help come on over to the Web Technology for Small Business and post your question (Notice the community badge on the right…)


About John Moore

John Moore is the co-founder of SonicSpider, LLC in San Diego County, California. John is our head Internet developer, overseeing the direction of our technical services. He has been programming in a variety of languages for more than 25 years, first as the owner of the consulting and system architect/design company, Micro-Phyla Systems, which provided services to enterprise level companies, and then as a principle with SonicSpider LLC. SonicSpider has two primary divisions, SonicWebTech for programming, ecommerce solutions, and general web oriented technical assistance - and RightStart Websites, specializing in WordPress, which provide low cost web packages and website enhancements that can span your needs from "do it yourself" to "do it all for me". John is also a PayPal Certified Developer and has extensive experience with many payment gateway solutions.
View John's Google Profile+
  • John, Really good and detailed instructions.Thanks