How to add AdSense code in your WordPress blog

Disclosure: This post may contain affiliate links. This is how we stay funded and these commissions are what keep our site going. Please support us by purchasing through our affiliate links.

So you have been working on your blog for a few months and now you want to earn some passive income.

Not every blog niche will earn the same amount, but there are some niches where you can earn a lot more.

So, what is Google Adsense?

It is a platform that allows publishers to earn money through display ads. Also, it’s completely hassle-free as it allows you to generate income without dealing with advertisers.

You just set up your AdSense account, paste the code and you will start to earn money.

A little reminder: Google Adsense is not the only platform that allows you to earn money through display ads. There are other ad networks where you can earn a lot more than Google Adsense. Do check it out.

Related article: Best ad networks for new bloggers

On this note, let me show you how you can create an Adsense account and how you can paste the code into your WordPress.


1. How to create Google Adsense Account

First, you will need to have a Gmail account to be able to create an Adsense account.

If you already have a Gmail account, then it will be pretty easy. 

Head over to Google Adsense and create your account.

Fill in the required information like your Url and email address and click on save and continue.

Now, you will be directed to Google Adsense’s terms and conditions where you will have to read and click on accept the agreement(Bottom of your screen).

Now click on continue to AdSense.


2. How to Add code to your WordPress blog manually

Next, you will be directed to the Google AdSense dashboard, where you will get your code.


Copy the code and head over to your WordPress Dashboard.

Note: Only copy the code, don’t click on done. You will have to paste the code then come back to Google Adsense to confirm that you have pasted the code.

In your WordPress dashboard, click on “Appearance” – Theme editor then choose Theme Header in the theme files section.

Paste the code just under the Head tag.

Now update the file and head over to your Google Adsense dashboard.

Select the “I have pasted the code” checkbox and click done. You will get a pop up that will tell you that approval is in progress. Click on “Got it”.

Pro Tip: Recently Google Adsense has announced auto ads, which means that you just paste a single code and your blog will start to show ads. I will show you how to do it later.


3. How to add Ad units to your blog manually

Once your account is approved, you will get an email confirming that your account is now ready to show ads. 

Generally, it takes anywhere between 24 to 48 hours to get approved for Adsense. Sometimes it can even take up to 1 to 2 weeks.

Now you will have 2 options. Either to create ad units and add them manually or you can enable auto ads.

Let’s start with creating ad units manually first.

Shall we?

Head over to your Adsense dashboard click on “Add” and press “Overview”.

Click on “By Ad Unit” and press on “Display Ads”.

Here you will get the option to choose from different ad formats.

You will get 3 choices:

  • Square ads – Perfect to display between paragraphs of your content
  • Horizontal ads – Usually placed on the top or just after the end of your content
  • Vertical ads – This is usually placed in your sidebar

For this tutorial, let’s create an ad unit that you will place in your sidebar (Be sure to select the responsive-top right of your screen).

Add a name to your ad a unit, and press on “create”.

Now you will get a code that you must paste on your blog. Select and copy the code.

There are 2 ways to do it. You can add the code manually or you can use a plugin.

First, let’s see how you can add the code manually.

Head over to your WordPress dashboard and navigate to “Appearance” and select “Widgets”.

Select the “Custom HTML” and drag it to your Main sidebar. Now paste the code and click on “Save”.


Voila. It’s done.

Simple isn’t it?

Now let’s see how you can use the plugin to add the Adsense code to your WordPress blog.


4. Adding Adsense code using Plugin

The best plugin I know is the Ad Inserter plugin. You don’t need to buy the premium version as the free version is enough to add at least 16 ads to your blog.

Install and activate the plugin.

Now head over to your WordPress dashboard, under “Setting” click on “Add “Inserter”.

Paste your code in the grey box.

You will see that you will get a lot of options under the grey box. Here you can choose to show the ads on specific pages and you can even choose where you will place the ads.

Once completed save the setting (Save settings 1-16).

The awesome thing about Ad Inserter is that you can create individual ad formats and place them wherever you want.


5. How to add and enable auto ads to your WordPress blog

Now if you don’t want to add codes individually, you can let Google determine the best places to show ads on your blog.

This option has allowed more people to use Adsense on their blog as they will have just to paste a code in The Header section of their blog.

One way to add the code is to insert it in your header PHP file.

But, there is a catch.

If ever you change your theme the code will disappear.

Therefore the best option is to use a plugin to solve this problem.

You will need to install and activate Insert Headers and footers plugin.

So head over to your WordPress dashboard and install and activate the plugin.

Once activated, head over to “Settings” and select “Insert headers and footers”.

Once you have pasted the code click on save.

The plugin will now add the code to all your pages and post. All you have to do is just wait till Google Adsense starts to show ads on your blog.


Bonus: Google Adsense Best Practices

Here are a few things that you should do:

  • You should always abide by Google Adsense terms of services to get approved quickly. 
  • Try different units to see which ones are performing better.
  • Quality content is the foundation and key to getting more out of your blog. The longer the content the more ads you can display.
  • Make sure your blog is mobile friendly and always strive to make your blog faster.
  • Try to conduct Google experiments to see which ads work best.
  • Always try to increase your Page’s RPM to increase your revenue.

Few things that you should avoid:

  • Do not add too many ads to your blog. The ideal number of ads is between 3 to 5.
  • You should never click on your ads nor ask family and relatives to do that for you. Google is pretty smart, and it will notice such behaviors. You don’t want your Adsense account to be canceled. Right?
  • Don’t buy traffic.


Final thoughts: How to add AdSense code in your WordPress blog

I hope by now you know exactly how you can add Adsense code to your WordPress blog.

If you want to increase your Adsense revenue, you should focus on creating quality content and bring more traffic to your blog.

Here are a few resources that will help you with that:


If you liked this post, please don’t forget to share it so that others can benefit from it.

How to add AdSense code in WordPress

See you soon!


Leave a Comment