Do you want to add AdSense to WordPress? The easiest way to have AdSense is using Plugins, though you’ll learn how to use AdSense on WordPress WITH and WITHOUT Plugins too.
You’ll have step by step tutorial about how to apply for AdSense, and how to use it on the WordPress site.
We will see Ways to add Adsense to WordPress without Plugins, add AdSense to WordPress Manually and have AdSense on WordPress using Free Plugins.
First of all, What is Google AdSense?
Google Adsense is Google’s Advertising network, which allows Websites and YouTube channels to earn revenue from their content. It majorly focuses on CPC (Cost Per Click), which means you get revenue on a per-click basis.
Once signed up for AdSense, it gives you code to start Advertising on your site. How much do you earn? Well depends on many factors, including what product is being Advertised, Location of Ad Clicker (Clicks from Viewers of USA, UK, Australia, and Canada generally have higher income), etc.
Can I use Google AdSense on WordPress?
Yes, AdSense doesn’t have official plugins for WordPress, but you can use AdSense by simple custom codes, or 3rd party plugins, or using AdSense manually. AdSense can be used with WordPress with a lot of customizations and techniques.
Can I use AdSense on a Free WordPress Site?
No, AdSense is assigned to domains/sites. Free WordPress sites are handled by WordPress.com and you cannot apply for them by yourself. You have to own a domain and have full control over it to Apply.
How to Get Started with AdSense?
Well, now the part begins where we will discuss getting started with AdSense. The initial steps until sign up are the same for all websites including WordPress. After you are approved, the steps are different for AdSense to WordPress.
First, you need to have a Gmail account, which most you would already have.
Then you need to go to AdSense Start and fill out a form.
This form is crucial. Google doesn’t want to Advertise on random sites. So it’s better to fill it carefully.
Here’s a useful Pro Tip to add AdSense to WordPress
Pro Tip: If you are having a new site, then it’s recommended to not Apply for AdSense directly. Google doesn’t want to Advertise on incomplete sites. Finish the UI, post 5-6 blog posts, and have a bit of following. Also, a good site load time and site having SSL are preferred.
AdSense approval can sometimes even take a week. But personally, for me, I was approved within 36 hours. This was because my 15-day old site, was already indexed on Google search, I already had free SSL from Cloudflare, and my site was fast, even after cheap hosting, and I had 7 blog posts published.
What are AdSense Auto Ads and AdSense Ad Units?
There are 2 major ways to Add AdSense to WordPress, these 2 ways in short can be called “Auto Ads” and “Ad Units”
While most people get excited hearing the word “Auto”, I shall say that both are equally good and it’s about personal preference.
Auto Ads and Ad Units are 2 major methods of adding AdSense to WordPress.
Let’s see what these 2 are in detail.
Auto Ads
Google’s AI understands User’s behavior, it can test 100s of different ways to find which Ad Placements work best for you. It is suitable for sites will less than 1,000 monthly unique views.
This feature is called “Auto Ads” in AdSense. Below are the Steps for Auto Ads in WordPress.
Auto Ads usually tries lots of variations, therefore you need to give it at least a month before you start seeing good results.
So how to add Google’s Auto Ads to WordPress.
First of all Head to AdSense, log in to your AdSense account if you haven’t already.
Now AdSense -> Ads -> Overview
Then under the heading, “Let Google place ads for you” you will see a button saying “Get Code”.

How To Add Adsense To WordPress
This will give you a code for your AdSense. The code has some data unique to you.
Do not share it with anyone. Throughout this creation, we will show you different images/snippers, in which you would have to replace the code with your unique AdSense code.
Clicking the Get Code button will give you Auto Ads code and Ads would look like this:

Adsense Auto Ads To WordPress
Ad Unit
You can place your AdSense code at your convenience and choice too.
To do this, you need to create an Ad Unit in AdSense. Ad unit is a unit of Ads that can be displayed on your site, can be repeated as you like it. Each Ad Unit can be configured with Settings such as dimensions and Ad Types.
To Create an Ad Unit, head to AdSense -> Ads -> Overview -> By Ad Unit.

Adsense Ad Units To WordPress
Here you can choose different types of Ad Units based on your needs.
It will generate a code, Google asks you to place the code wherever you want ads.
The code Google gives is fine. But I have a better approach for you. This will make your workflow easy, give you manual control, and also make your site relatively faster.
The code here looks something like this.

How To Use Adsense Ad Units On Your WordPress Site
Now, this code can be split into 2 parts, the First Script can be considered one part, and the and second script together can be considered the second part.

Parts Of Ad Unit Code
These 2 codes will be put into the post separately, for maximum performance
Also, in case you want to improve the performance of your WordPress site, do check out 17 Secrets to How I Optimize My WordPress Site To Load In 927 ms (100% GTMetrix)
How to add AdSense to WordPress

Ways To Add Adsense To WordPress
Once you have been approved for AdSense, you have to do the crucial part of using AdSense with WordPress.
There are 3 major approaches for AdSense on WordPress.
- Add Adsense to WordPress without Plugins
- Manually Integrate AdSense and WordPress
- Free WordPress AdSense Plugins
We will discuss all of them. Adding WordPress AdSense Without Plugins is my favorite approach. Though it requires an FTP and a bit of control over plugins. Though it works great.
Now some of you do not like to have so many plugins, and as a result prefer to have an approach without plugins, basically using your custom code. So now we will discuss everything we did with AdSense, but using nothing but our coding. We will not be using any 3rd Party plugins.
How to add AdSense to WordPress without Plugins

How To Add Adsense To WordPress Without Plugins
The code is easy to customize to ensure an easy workaround for beginners too. Some Code is way too intense for even moderately experienced Programmers to understand. So, I shall suggest you avoid this and move directly to our Next Section of Manually Adding AdSense to WordPress.
If you are still willing to bridge Adsense to WordPress without Plugins, we will now show you how to do that.
There are 3 basic approaches to do that.
- Use Google AdSense Auto Ads on WordPress
Place Ad Units for AdSense to WordPress Posts Using Shortcodes
Automated Google Ads Placement Using Repetition
Use Google AdSense Auto Ads on WordPress
Now you need to place this code on every single page on your site. How to do that?
Well, as we are discussing how to add AdSense to WordPress without Plugins, I will tell a method for custom code. Don’t worry in case you want to do it with plugins, I will tell you the method for the same later, you can scroll down to “Manually add AdSense to WordPress” for that. For now, let’s focus on doing it without plugins.
So we are now going to do Google AdSense Auto Ads. Auto Ads use Google’s Algorithm to automatically place ads wherever needed.
We already explained how to get Google’s Auto Ads code for your site above, scroll to “What is AdSense Auto Ads and AdSense Ad Units” for that.
Anyways so you need to create a child theme, or a custom plugin to add the necessary Code. If you already have a plugin/Child Theme use that, if not create a new one. If you don’t know how to create plugins, refer to How to Create Custom Plugins in WordPress
Now below I will share the code that you need to add to make add AdSense.
WARNING: Google Gives slightly Different Code to each site. Please copy the code from AdSense and paste it INSIDE the inverted commas of $GoogleCode.
function MilyinScripts(){
$GoogleCode = '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxxx" crossorigin="anonymous"></script>';
echo $GoogleCode;
}
add_action('wp_head', 'MilyinHead');
This code will directly Ad Scripts to your WordPress Head, and make it work everywhere on site.
For that, you can directly paste the code from AdSense in Header.php in your site theme, but it’s not recommended.
Some people prefer to have ads only on their blog posts.
And they question How to use AdSense for WordPress Blog Posts only.
It’s simple, but I will still share the code for the same.
Note: I love Coding, And I am willing to help you all. If any reader wants help with anything related to AdSense, you can comment below and I will help you out for sure. (It’s free to register)
So here’s the code to have AdSense only on Posts in WordPress:
WARNING: Google Gives slightly Different Code to each site. Please copy the code from AdSense and paste it INSIDE the inverted commas of $GoogleCode.
function MilyinScripts(){
$GoogleCode = '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxxx" crossorigin="anonymous"></script>';
global $post;
if( !is_preview() && is_single() {
echo $GoogleCode;
}
}
add_action('wp_head', 'MilyinHead');
I hope you enjoyed it.
Also, if you want to implement it without the Coding, I will share the other method where you can implement it without plugins later in this creation.
Place Ad Units for AdSense to WordPress Posts Using Shortcodes
The first part of the code is in Head as we did earlier.
To place Ads at particular locations, you need to use Ad Units.
We explained how to get code for Ad Units earlier. We spilt the AdSense code into 2 halves.
The process to add the first part is simple.
WARNING: Google Gives slightly Different Code to each site. Please copy the code from AdSense and paste it INSIDE the inverted commas of $GoogleCode.
function MilyinScripts(){
$GoogleCode = '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxxx"
crossorigin="anonymous"></script>';
echo $GoogleCode;
}
add_action('wp_head', 'MilyinHead');
The first code which we added above sets up the assets and data from Google to fetch Ads and Advertising information.
But simply having this code will not add Adsense to WordPress. You need to add the second part of the code too.
The second part of the code is (in a way) the actual ad. Wherever the 2nd code is placed, the ad will be shown.
So, here we will discuss how to convert the 2nd part of the code into a shortcode for easily inserting in posts.
Below is the code to build a shortcode. This shortcode placed anywhere inside your post will output the “2nd Part” of your AdSense Ad Unit code and therefore build your Advertisement.
WARNING: Google Gives slightly Different Code to each site. Please copy the code from AdSense and paste it INSIDE the inverted commas of $GoogleCode.
function AdSenseShortcode() {
ob_start();
$GoogleCode = '<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" data-ad-slot="xxxxxxxxxx" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script> (adsbygoogle = window.adsbygoogle || []).push({});</script>';
global $post;
if(!is_preview() && is_single()){
echo $GoogleCode;
}
return ob_get_clean();
}
add_shortcode('AdSenseShortcode', 'AdSenseShortcode');
Remember to replace the code you received from AdSense in $GoogleCode.
This will create a shortcode [AdSenseShortcode], now wherever in your post, you want an advertisement to exist, put [AdSenseShortcode] instead.
Automated Google Ads Placement Using Repetition
This technique will allow you to automatically insert 2nd part of the code, in your Post at regular intervals.
You need to remember that you need the first part of the Ad Unit code too.
The process to add the first part of the code is the same here also. But I will still explain.
WARNING: Google Gives slightly Different Code to each site. Please copy the code from AdSense and paste it INSIDE the inverted commas of $GoogleCode.
function MilyinScripts(){
$GoogleCode = '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxxx"
crossorigin="anonymous"></script>';
echo $GoogleCode;
}
add_action('wp_head', 'MilyinHead');
The first code which we added above sets up the assets and data from Google to fetch Ads and Advertising information.
Now for the second part, we will use automation.
Below is a slightly longer PHP code, that will automatically add the second part of code to WordPress wherever needed.
There are 3 things in the given code you need to change.
$InsertAfter defines the number of paragraphs after which repetition starts. Usually, it is recommended to avoid ads in 5-6 Paragraphs of the Post.
Once Ad starts inserting we need to decide the gap between 2 consecutive Ads.
$GoogleRepetition defined this gap. I Repeat it after every 4 Paragraphs but you can change it yourself.
Then $GoogleCode should have your 2nd Part of the AdSense Ad Unit Code that you got. (Remember the first part of the AdSense Code has to be inserted via the codes that we discussed earlier.)
For User Experience Standpoint, I usually wrap my AdSense code in a Div, but you can skip that if you want.
Also, if you are like me and love coding, here 23 Most Useful WordPress Code Snippets for Performance, SEO, and Security
function AdBlock( $Content ) {
if(!is_preview() && is_single()) {
$InsertAfter = 8; //number of paragraphs to skip before starting Ads
$GoogleRepetition = 4; // After starting Ads we have repeat after how many paragraphs.
$GoogleCode = '<div class="AdSense"><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-xxxxxxxxxxxxxxxxx" data-ad-slot="xxxxxxxxxx"></ins></div>';
$Split = "</p>";
$Code = '';
$Paragraphs = explode( $Split, $Content);
if ( count( $Paragraphs ) > $InsertAfter ) {
$i = 1; // current ad index
foreach( $Paragraphs as $Paragraph ) {
if($i > $InsertAfter){
if($i % $GoogleRepetition == 0){
$GoogleAd = $GoogleCode;
}
else {
$GoogleAd = '';
}
$Code.= $GoogleAd . $Paragraph;
}
else{
$Code .= $Paragraph; // new text
}
$i++;
}
return $Code;
}
return $Content;
}
return $Content;
}
add_filter('the_content', 'AdBlock');
Hope you liked it.
These codes are a bit complex, and I would not recommend you to try them if you have 0 experience.
Also, if you want I can help you with the code, you can contact me in the comment section, or message me by registering on this site for free.
Now we will see how to implement everything above using Plugins.
How to Add AdSense to WordPress Manually

How To Add Adsense To WordPress Manually
You can add AdSense to WordPress manually.
This method is simple and usually good unless you want to implement advanced strategically placed ads with lots of variables and conditions, and clutter, etc., etc.
This is basic yet powerful.
You can Place Ads Manually by 2 Methods:
- Use Google AdSense Auto Ads on WordPress
- Place Ad Units for AdSense to WordPress Posts Using Shortcodes
Use Google Algorithm to Automatically Place Ads
This is the same as placing Google Auto Ads into your Blog Posts.
You can add Google AdSense to the WordPress site easily if you use simple lightweight plugins.
We have already discussed how to get Auto Ads code in WordPress. So I will request you to scroll up to read that if needed.
You need to place this code in your header.
Well, the easiest way to add Auto Ads to WordPress, is using plugins, most notably the Insert Headers and Footers WordPress plugin,
Simply Install and Activate it go its a page in wp-admin and paste the below code.
WARNING: Google Gives slightly Different Code to each site. Please copy the code from AdSense and paste it INSIDE the inverted commas of $GoogleCode.
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxxx" crossorigin="anonymous"></script>
This code will directly Ad Scripts to your WordPress Head, and make it work everywhere on site.
It’s simple to use and works great.
If you are a little bit familiar with WordPress wp-admin interface it would be super easy for you.
Place Ad Units for AdSense to WordPress Posts Using Shortcodes
I would be showing you to put AdSense Ad Units code into your post.
First, you need to have the AdSense Code for the Ad unit.
I have explained it earlier, please scroll above and read that.
This may require WordPress plugins based on Use care, but the benefit of Adding Adsense to WordPress Manually is that you get a lot of control.
You need to place the first part only once in a URL, so I would say place it in Header, the easiest way to add this in WordPress, is using the plugin, most notably the Insert Headers and Footers WordPress plugin.
The second part of the code should be directly added inside your post wherever you want your ad to appear.
No need for the first part here, just put the second part wherever you want your ads to appear. If you want your Ads to appear at 10 locations, paste the second part of ShortCode at all those 10 locations.
Sometimes this code can mess with your post, and conflict with some plugins. So an even better yet optional approach would be to use a plugin, like Shortcoder, in this plugin add the 2nd part of the code and save it.
WARNING: Google Gives slightly Different Code to each site. Please copy the code from AdSense and paste it INSIDE the inverted commas of $GoogleCode.
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxx" data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script> (adsbygoogle = window.adsbygoogle || []).push({});</script>
Now insert this shortcode in your post wherever you want ads. It looks clean, is easily editable in long run, and also prevents plugin conflicts.
Now let’s get into Advanced use cases to add AdSense to WordPress.
This is the easiest and most effective for newcomers. I shall say that these would be heavy plugins, build specifically for adding AdSense to WordPress.
Free WordPress AdSense Plugins

How To Use Free Plugins To Add Adsense To WordPress
We have some of the Best WordPress Adsense Plugins. All of them are free, as I understand most of the new business owners have insufficient funds to invest in Paid Plugins.
For people new to WordPress, these plugins feel like heaven, and therefore many love them.
I personally never use plugins, because the best plugins come with lots of customization options, and they make my site heavy.
However when I was new to WordPress even I used Plugins to Add Adsense to my WordPress site.
Some of them are great, using advanced algorithms to place ads at suitable locations. This is something you cannot easily achieve with code if you are not a Pro.
Besides that, for the majority of busy bloggers, time matters more.
Most of the bloggers don’t have time to waste over coding, and therefore having a plugin that works flawlessly and reduces your efforts can be really helpful.
So let’s begin
Easy Google AdSense is a plugin built for simplicity.
As the same suggests it is meant to be easy, it manages everything for you. You just need to put in the AdSense Publisher ID, and it would automate everything for you.
It doesn’t give you control and is not customizable.
However, it is well built and good for performance, along with that it is easy to operate and reliable.
Quick AdSense
It is a great plugin, for beginners, in fact even before I learned to code this was my go-to Plugin because it is simple, easy to use, performance-oriented, and reliable.
It gives you granular control over where to add Adsense to WordPress while still allowing scope for experimentation.
It allows you to randomize and try different Ad Styles, Ad Placements, and Ad Styles without any changes.
This is particularly useful in the early days as it allows you to understand what is working best for your site.
Google AdSense Dashboard
Google AdSense Dashboard is an excellent plugin. I would suggest you give it a shot even if you are using coding or other manual methods to insert ads.
It allows you to know your AdSense analytics directly from your WordPress dashboard and further allows you to be able to generate reports from then and there.
It’s simple and allows you to better understand the data.
Data is the real king when it comes to cracking the perfect recipe for AdSense.
Advanced Ads
Advanced Ads is a really good plugin for #AdSense to WordPress. One of the best things about this plugin is that it includes an Ad Blocker remover.
Netizens using AdBlocker would be asked to remove/disable AdBlocker to view posts.
These Ad Blockers real harm the profits of Websites, and therefore this can give you an additional advantage over the rest of the competition.
Conclusion
#WordPress is awesome, and it has a variety of methods to implement #monetization using AdSense.
In case you were lazy enough to ignore the 3000 words above and scroll right to the bottom to read Conclusion, no worries I will help you understand everything in short.
I hope you enjoyed my guide on how to add AdSense to WordPress, comment below if you have any other approaches or some other useful plugin/code that you use for AdSense on WordPress.
There are 3 major approaches to it. Add AdSense to WordPress without plugins using Custom Code. This approach is really good for Pros, who have a bit of knowledge of Code, here we implement AdSense using 3 methods, we can either use AdSense using Auto Ads, or we can use AdSense Ad Units, these Ad Units can be implemented using WordPress Shortcodes, or using a code that inserts the Ad Unit after regular intervals in your post.
The next approach to add AdSense to WordPress is a manual approach, where you paste code wherever needed. In the case of Auto Ads, this code is pasted directly into the header of the theme. For Ad Units, the 1st part of the code goes in the header and the 2nd part of the Ad Unit code is pasted wherever needed. Though you can use plugins like Insert Headers and Footers, or plugins like Shortcoder to make the work easy.
The third approach involved directly using plugins to make it work better. All approaches work nicely but this approach is really good for those who don’t want to be involved in code. These plugins are advanced and built with experience, thus allowing you options to optimize your content better.
In case you face any difficulty, I would gladly help you out. You can comment below and I will surely help you out.
Last Updated:
Views: 60