Adding Google AdSense Code To Your WordPress Blog

in WordPress Tutorials

Lets be honest, most sites are designed to provide some form of advertising or income. After all the internet is basically the market of the 21st century, most everyone has some type of income tied directly to it. So what good is a WordPress theme that is not completely compatible with advertisements like Google Adsense?

Some themes come with pre-configured support for advertisements and related options, but for those few that don’t provide ad support, this tutorial will explain how to implement the features.

What the term “pre-configured theme” means is that the related theme basically allows “easy” placement and editing options without any advanced editing requirement. The real truth however is that every theme could potentially become ad compatible.

First however, you will need to decide what size space you are working with and how big you would like the ad to appear on your page. The more conventional ad sizes are listed below, but you could realistically alter the ad to fit any size space.

  • Horizontal Banner: (468×60)
  • Leaderboard: (728×90)
  • Perfect Square: (250×250)
  • Vertical Banner: (120×600)
  • Skyscraper: (160×600)
  • Rectangle: (300×250)
  • Large Rectangle: (336×280)

Direct Source File Editing (Manual) Method

In order to manually insert ads into your website, you will have to directly enter code into each section of your page where you would like the ads displayed.

If you aren’t already aware, each page is broken up into various sections which consist of the following: the header (top), the sidebar, the site index (page listing), the posts, and the page template (static page section which appears on every page).

To manually add the Google Adsense ads onto your site the source “page.php” file will need to be edited. This will ensure the ads display on all available pages within the site, eliminating the need to manually add the code to every single page individually.

First, you will have to sign into your Google AdSense account and create a new ad unit. Then after editing the ad options and saving the ad you must copy the entire advertisement code to the clipboard in order to continue.

Insert the code you copied into the file which indicates the location you want the ad to show. For instance, if you want the ad to appear in the header of your page then you would insert the code into the “header.php”. Make sure not to break up previous html commands, meaning input the code on a fresh line outside of any previous command tags.

Adding Google AdSense Through A WordPress Widget

Google AdSense ads can also be added to a WordPress blog or site through the use of text widgets. Instead of manually editing code and changing the theme source files users can add AdSense code via the “Appearance > Widgets” WordPress Dash-board menu.

To begin, simply drag a “text” box widget into the column on the right hand side of the screen (after choosing where you would like the advertisement to display of course; header, body etc.). Click on the right side of the “text” widget box, the arrow should drop down and display a menu. Copy your ENTIRE Google AdSense code (after creating a new ad unit) and paste it into menu below the “text” widget.

When finished select the “save” button displayed below the “text widget, this will obviously save any changes which have been made to the theme and activate them. The maximum number of Google AdSense ads per page is 3, so remember this when adding additional “text” widgets in the future.

That’s it, all done! But there’s one more step to adding Google AdSense ads.

Creating a Privacy Policy Page

Google requires that any affiliate or website displaying AdSense ads must also include a Privacy Policy, which basically provides a cookie disclosure notice. In simple terms it just means the site owner must provide a warning for all visitors that the site is using AdSense to alter their computer’s cookies and browser cache files.

According to Google: “AdSense publishers must have and abide by a privacy policy that discloses that third parties may be placing and reading cookies on your users’ browsers, or using web beacons to collect information as a result of ad serving on your website.

The first step is to create a personalized Privacy Policy message which will appear on the page and then implement it into your website. For more information on what to say or talk about in a Privacy Policy refer to the Google Advertising Privacy Policies page.

Next either create a page that displays when the user first visits your site or create a “text” widget using the method above and display the Privacy Policy text within. Either method will work fine, but failure to add a Privacy Policy message will render your AdSense advertisements useless on the site.

Comments (5)

  • Comment by Vishesh Kachheda
    Vishesh Kachheda

    Thanks for the Post Mate!!
    Really Helpful!

  • Comment by Matthew

    I appreciate the help with this. Good info!

  • Comment by daoudi mp3
    daoudi mp3

    I really like and appreciate your site.Nice theme
    thanks very much for publishing such as this topic and waiting for your next update

  • Comment by Narendra Chuahan
    Narendra Chuahan

  • Comment by John Flower
    John Flower

    Thanks for the post. Sheesh, the privacy policy thing… I probably need to do something about that.
    Here’s a nifty page Google set up with all their ad sizes:

    Very handy to get a visual idea.