How to Add Google Adsense Code to WordPress | The Right Method!
In this tutorial, I will show you how to add Google Adsense code to the WordPress site using the right method. Yes, the right method means, just add single Google Adsense JavaScript and place the ads on the places you want. Also, the right method means to add Google Adsense JavaScript to the Footer, not in the Header. This way it will eliminate the JavaScript render-blocking warning. I am sure, that if you will use this method to add Adsense code to the WordPress site, it will not impact your website performance. Because if you put the Adsense code in the Head tag (<head></head>), it will definitely impact your WordPress site performance, which you can test using the website speed test tools such as Google PageSpeed and GTmetrix, etc.
Now I already brief you about it, that what are the advantages of adding Google Adsense Main JavaScript code to the Footer in WordPress site. So let's start the tutorial.
Note: your Adsense JavaScript code may be different as shown in the above image because of Google code updates.
After enabling the Adsense auto ads, it is itself sufficient to show Ads on your site automatically in the appropriate places and this is the also right method. But mostly, we want the Google Adsense to show the ads on the places selected by us. To do this, follow these steps:
[right-side] After copying the Adsense code, you no need to paste the full code because you have already added the main JavaScript (<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>). And if you will add full code then it will unnecessarily increase the JS code in your WordPress site, which will have a bad impact on your site. To take a specific part of this code, paste this code into a text editor and copy the only part as shown in the below example:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-xxxxxxxxxxxx"
data-ad-slot="11xxxxxxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Then click on the Publish button to save the changes and to make it live on the site. Google takes 4 to 5 minutes depends on your website traffic to display the ad.
To place the ads above posts or between posts follow this step:
Now click on the Post Adverts > Add New Post and paste the Adsense Ad code as shown in the 7th step. Here you can specify the display position of the ad to above post or below the post and after a specific paragraph, as shown in the below image:
This way you can add the Adsense code anywhere in your WordPress website.
So in this tutorial, you have learned the right method to add Adsense code to the WordPress site.
Related tutorial:
Now I already brief you about it, that what are the advantages of adding Google Adsense Main JavaScript code to the Footer in WordPress site. So let's start the tutorial.
Steps to Add Google Adsense Code to WordPress Using the Right Method
1. Get Google Adsense Main JavaScript Code
First, get the Google Adsense Main JavaScript code from the Adsense. To do this, open your Google Adsense Account page and click on the Ads and then from the right side pane click on the Get Code link to get the Single Google Adsense JavaScript code, as shown in the below image:2. Install Plugin in WordPress to Insert Adsense Code to the Footer
You have copied the Adsense JavaScript code, now you have to install a plugin, through which you can add the code in the footer. To do this, open the WordPress click on the Plugins > Add New and search for the Header and Footer Scripts. You will find the Header and Footer scripts plugin as shown in the below image. Now click on the install button and then Activate it.3. Open the Header and Footer Script Page
After activating the plugin, click on the Settings > Header and Footer Scripts as shown in the below image:4. Add Google Adsense Code to WordPress
Now paste the Google Adsense JavaScript code in the Footer scripts area as shown in the below image:Note: your Adsense JavaScript code may be different as shown in the above image because of Google code updates.
5. Enable Adsense Auto Ads
To enable Auto Ads, you need to click on the Pencil icon right side of your website name to enable Auto Ads. This is the page from where you copied the Adsense JavaScript code. Below is the image:After enabling the Adsense auto ads, it is itself sufficient to show Ads on your site automatically in the appropriate places and this is the also right method. But mostly, we want the Google Adsense to show the ads on the places selected by us. To do this, follow these steps:
6. Create an Ad and get the JavaScript code
To create an Adsense Ad, click on the Overview page > By Ad Unit and then select the Ad type as shown in the below image:7. Save and Get the Ad Unit Code
After completing the Ad creation, save and get the code. As shown in the below image:[right-side] After copying the Adsense code, you no need to paste the full code because you have already added the main JavaScript (<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>). And if you will add full code then it will unnecessarily increase the JS code in your WordPress site, which will have a bad impact on your site. To take a specific part of this code, paste this code into a text editor and copy the only part as shown in the below example:
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-xxxxxxxxxxxx"
data-ad-slot="11xxxxxxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
8. Place the Adsense Code in Website's Widget Area
To place the above Adsense code in the WordPress site, click on the Appearance > Customize > Widgets > select the widget area and then add an HTML type widget and paste the above code in it.Then click on the Publish button to save the changes and to make it live on the site. Google takes 4 to 5 minutes depends on your website traffic to display the ad.
To place the ads above posts or between posts follow this step:
9. Add Adsense code in the Post in WordPress
To insert ads between the WordPress posts, you need to install a plugin Post Adverts. To do this, click on the Plugins > Add New and search for the Post Adverts. Then install and activate the plugin.Now click on the Post Adverts > Add New Post and paste the Adsense Ad code as shown in the 7th step. Here you can specify the display position of the ad to above post or below the post and after a specific paragraph, as shown in the below image:
This way you can add the Adsense code anywhere in your WordPress website.
So in this tutorial, you have learned the right method to add Adsense code to the WordPress site.
Related tutorial:
Comments
Post a Comment