How To Add Google Adsense Ads In Your WordPress Themes

Google AdSense is a quick and easy way to make money online. It allows web publishers to display Google ads related to their website content and convert traffic into income.

WordPress is a popular content manage system in the world today, hundred of thousands website is created with it. There are a lot of WordPress hosting provider ( such as ) that can help you to create, optimize your WordPress website.

This article will tell you how to add google Adsense ads in your WordPress website.

1. How To Apply Google Adsense.

Go to to create an adsense account. If you already have a google email account then you can use that account to apply adsense account.

During the apply process, you had better provide your website domain which you want to display ads to google adsense group and wait for their approve.

After approve you can create and add ad units in your website. You can see the income increase if your website has a lot of high quality traffic.

But if you want to get those money into your pocket, you had to apply google PIN code by post mail ( not email ), and when you get the PIN code, you need input it in verify address page to verify.

Sometimes you can not get the PIN code by post mail, you have three choice to apply the PIN code by post mail. If after three times, you still not get the PIN code, you can apply it online by submit picture of your identification card, credit card bill statements etc. Please note the name and address in ID card or credit card bill statements must be same with the post mail name and address.
google adsense input pin code page

2. Create And Add Google Adsense Ads In WordPress.

There are two type of ads that you can create in google adsense. They are Auto ads and Ad units. Login to google adsense, click My ads —> Content menu item in left panel to see them.

google adsense ad type auto ads, ad units

2.1 Auto ads

You just need to add one line JavaScript code inside the page <head> area, and then configure which page you want the ad to display. Google will display related ads automatically in your pages with appropriate ad number at best place.

Google said it use machine learning technology to know where and how many ads is just fit for your pages. This can make publisher focus on the content and do not need to care about ad number and position.

Google also said auto ads can make publisher’s revenue increase 10 to 15 percent than manual ad units. But i think this need time to verify, because google just release auto ads feature in Feb 2018, it is not a long time.

From this article i learned google auto ads can increase revenue only based on manual ad units. And i test the auto ads in my website ( ) for two weeks also. I really find that if only display google auto ads, the revenue will drop down. So you had better use the auto ads as a added option to manual ad units, then it can give you more money than original.

If you have used google adsense before, you should know page-level ads, now Auto-ads just replace the page-level ads, so you do not need to care about page-level ads anymore.

2.1.1 How To Enable Auto ads.
  1. Click My ads —> Content —> Auto ads menu item to go to auto-ads settings page.
    google adsense my-ads content auto-ads
  2. Click GET STARTED button then you can enable or disable numerous auto ads format as below. Because i want to use google adsense auto-ads as added option to my manual ads units, so i just enable In-articles ads format. This ad format is not easy to configure in ad units because of ad display position.
    google adsense auto ads format
  3. After enable ad format, click Save button at bottom right of the page. Then it will show you a page that include the JavaScript code which you need to place in your page <head> section.
    google adsense auto ads javascript code
  4. Click COPY CODE SNIPPET link to copy the code in clipboard then add them at the beginning of your WordPress website page <head> tag.
2.1.2 Copy Auto-ads JavaScript In WordPress Page Head Tag.
  1. Log into WordPress management console as administrator.
  2. Click Appearance —> Editor menu item in left panel. In right panel, choose the theme which you want to edit in the drop down list and click Select button. Click the header.php in all the listed files and paste the adsense auto-ads JavaScript code at the beginning of <head> tag.
    add google adsense auto-ads javascript in header.php file
  3. This method has below disadvantages, when the theme update or changed, the head tag may also changed, so you need to add the JavaScript code again. To avoid the issue, you can use some WordPress header plugin to add the JavaScript code.

2.2 Ad units.

Ad units is the traditional adsense ads that has been used for many years. If you place ad units in right position with right ad numbers, it can give you much revenue.

Now google do not limit the ad units numbers, you can add any numbers as you like. But you must abide by google’s webmaster guide, the ads can not influence user experience of the page content, otherwise your web site will be banned by google search engine algorithm.

2.2.1 Create Ad Units.
  1. Click My ads —> Content —> Ad units menu item to go to ad units list page.
  2. Click New ad unit button to add a new ad unit. You can select the ad units format based on the position where you want to place the ad at.
  3. After that you can see the created ad units in the list page, click Get code link in each ad unit to get the ad JavaScript code.
    google adsense ad units list page
2.2.2.Add Ad Units In WordPress Article.

Now you can add those manual created ad units in your WordPress articles, you have two options to insert those ad units JavaScript code commonly.

  1. Add ad units inside articles, such as in page header, footer, before post, before content, after paragraph, after content and after post etc. You can use WordPress pulgin Ad Inserter to implement this.
    use ad inserter to add ad units wordpress page
  2. Add ad units in theme sidebar. You can use Custom Html widget to add code block in sidebar and then copy the ad unit JavaScript code into it. Login to WordPress as administrator, click Appearance —> Widgets menu item in left panel, in right panel drag and drop Custom Html widget to the sidebar, and paste ad units JavaScript code into it.
    add adsense ad units javascript in sidebar with custom html widget
  3. If you want the sidebar ad still be shown when user scroll down to the page bottom, you can use a widget which is called Q2W3 Fixed Widget (Sticky Widget). This widget can make the ad sticky to the sidebar bottom when you scroll the page down. But this action maybe banned by google search algorithm because sticky ads in not allowed in google webmaster guide.

Notice : When update WordPress theme, do not forget modify themes header.php, because google analytics tracing JavaScript code and google auto-ads JavaScript code are all placed in that file.

0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x