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 management system in the world today, thousands of websites are created with it. There are a lot of WordPress hosting providers ( such as bluehost.com ) that can help you to create, optimize your WordPress website.

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

1. How To Apply Google Adsense.

  1. Go to http://adsense.google.com to create an AdSense account. If you already have a google email account then you can use that account to apply AdSense account.
  2. During the applying process, you had better provide the website domain that you want to display ads to the google AdSense group and wait for their approval.
  3. After approval, you can create and add ad units to your website. You can see the income increase if your website has a lot of high-quality traffic.
  4. But if you want to get that money into your pocket, you had to apply the google PIN code by post mail ( not email ), and when you get the PIN code, you need to input it into the verify address page to verify.
  5. Sometimes you can not get the PIN code by post mail, you have three times to apply the PIN code by post mail. If after three times, you still do not get the PIN code, you can apply it online by submitting a 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 the same as the post mail name and address.

2. Create And Add Google Adsense Ads In WordPress.

  1. There are some types of ads that you can create in google AdSense. Such as Auto ads and Ad units.
  2. Login to Google AdSense, click Ads —> Overview menu item in the left panel, then you can find three tabs on the page right side.
  3. The three tabs are By site, By ad unit, Global settings.

2.1 Auto ads

  1. 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 on your pages with the appropriate ad number at the best place.
  2. Google said it uses machine learning technology to know where and how many ads are just fit for your pages. This can make publishers focus on the content and do not need to care about ad number and position.
  3. Google also said auto ads can make publisher’s revenue increase 10 to 15 percent than manual ad units. But I think this needs time to verify because google just releases the auto ads feature in Feb 2018, it is not a long time.
  4. From this article, I learned google auto ads can increase revenue only based on manual ad units. And I test the auto ads on my website ( dev2qa.com ) for two weeks also. I really find that if only displays google auto ads, the revenue will drop down. So you had better use the auto ads as an added option to manual ad units, then it can give you more money than the original.
  5. 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 Ads —> Overview menu item on Google AdSense dashboard left panel.
  2. Then click the By site tab on the page right side, it will list all the websites in Google Adsense.
  3. Click the Edit button at the end of one website line, then it will open the Ad Settings Preview page.
  4. On the page right side click the Ad settings tab.
  5. Then you can switch the Auto ads toggle button to enable or disable the auto ads for the selected website.
  6. You can expand the Ad formats section to select the Auto ads format, it contains In-page ads, Anchor ads, Vignette ads.
  7. When you finish your configuration, you can click the Apply to site button to save the above settings, and it will return back to the website list page ( you can also click the Ads —> Overview menu item to go to this page).
  8. Click the blue Get code link on the above page to get the AdSense auto-ads JavaScript code in a popup dialog.
2.1.2 Copy Auto-ads JavaScript In WordPress Page Head Tag.
  1. Log into WordPress management console as an administrator.
  2. Click Appearance —> Editor menu item in the left panel. In the right panel, choose the theme which you want to edit in the drop-down list and click the Select button.
  3. Click the header.php in all the listed files and paste the AdSense auto-ads JavaScript code at the beginning of the <head> tag.
  4. This method has a disadvantage, when the theme update or changes, the head tag may also be changed. So you need to add the JavaScript code again.
  5. To avoid the issue, you can use a WordPress plugin Insert Headers and Footers to add the AdSense auto-ads JavaScript code.

2.2 Ad units.

  1. Ad units are the traditional AdSense ads that have been used for many years. If you place ad units in the right position with the right ad numbers, it can give you much revenue.
  2. Now, Google does 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 the user experience of the page content, otherwise, your website will be banned by google’s search engine algorithm.
2.2.1 Create Ad Units.
  1. Click Ads —> Overview menu item on the Google AdSense left side.
  2. Click the By ad unit tab on the page right side.
  3. You can create five types of AdSense ad units, they are Display ads, In-feed ads, In-article ads, Matched content, Search engine.
  4. After creating the ad units, you can see the created ad units on the Existing ad units list page.
  5. Click the Get code link at the end of each ad unit to get the ad unit JavaScript code.
2.2.2.Add Ad Units In WordPress Article.
  1. Now you can add those manually created ad units in your WordPress articles, you have two options to insert those ad units JavaScript code.
  2. 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 the WordPress plugin Ad Inserter to implement this.
  3. Add ad units in the theme sidebar. You can use the Custom Html widget to add code block in the sidebar and then copy the ad unit JavaScript code into it.
  4. Login to WordPress as administrator, click Appearance —> Widgets menu item in the left panel, in right panel drag and drop Custom Html widget to the sidebar, and paste ad units JavaScript code into it.
  5. If you want the sidebar ad still to be shown when the user scrolls 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 may be banned by the google search algorithm because sticky ads are not allowed in the google webmaster guide.
  6. Notice: When updating the WordPress theme, do not forget to modify themes header.php, because google analytics tracking JavaScript code and google auto-ads JavaScript code are all placed in that file. So it is better for you to use the WordPress plugin Insert Headers and Footers to insert javascript source code in the website page’s header section.

Subscribe to receive more programming tricks.

We don’t spam!

Subscribe to receive more programming tricks.

We don’t spam!

1 thought on “How To Add Google Adsense Ads In Your WordPress Themes”

Leave a Comment

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

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