In this guide, you'll learn how to add AdSense code to your website.
There are two recommended ways to do this on WordPress websites.
First, it is through the official Google AdSense plugin, and second, by making simple changes to your WordPress files (my preferred way).
Let’s see these two methods in more detail.
1. How To Add Google Adsense To WordPress? (With A Plugin)
The official way to add AdSense code to your WordPress website is using the Site Kit Plugin (developed by Google). Site Kit lets you connect your WordPress website to your AdSense account and place the necessary code on your website pages.
This is the easiest way to start showing AdSense ads on your website without coding or manually changing your website's files.
Before adding the code, it's a pre-requisite that you have a Google Adsense account.
Follow these steps:
- Download and install the plugin from the WordPress repository. Here is the link.
- Activate the plugin.
- Setup Site Kit by clicking the Start Setup button.
- Go to Settings, and under Adsense, click Connect Service.
- Click to Allow Site Kit to add the AdSense code to all your website pages and versions.
For ads to show on your website, you must enable Auto Ads in your AdSense account. Here is how to do this:
- Log in to your Google AdSense Account
- Go to Sites and click the Edit Button next to your site’s name.
Check the Auto Ads checkbox.
Note: If you decide to use the plugin, make sure that you remove any AdSense ad placements that you added to your website without the plugin.
2. How To Add Google AdSense To WordPress Without Plugins?
To add the AdSense code to your WordPress website without using a plugin, follow these steps:
Step 1: Get the AdSense Code
- Log in to your AdSense Account.
- Click Ads.
- Click The Get Code button.
- Click Copy code snippet.
Step 2: Add Code To WordPress
Once you have your AdSense code, you must add it to the <HEAD> of all your pages.
Follow these steps:
- Login to your WordPress Dashboard.
- Go to Customize under Appearance.
- Select Theme Settings.
- Select Header / Footer Scripts.
- Paste the AdSense code in the Header Scripts text box.
- Click the Publish Button.
After adding the code, you must return to your AdSense account and click the VERIFY button (under Sites) to verify your installation.
You must also enable Auto-Ads (as explained) above to start showing ads on your website. You can configure the different options (Overlay formats, In-Page Formats, Excluded areas, Excluded Pages) to define how many ads to show and other settings.
How To Place Ads Units Manually On Your Website (Without Using Auto Ads)
If you don't want to use Auto-Ads and place the ads manually on your website, add the code as explained above but keep the Auto-As option disabled.
On a typical WordPress blog, you can place AdSense ads in the following places:
- In the sidebar (widget).
- On top of the page (below the header).
- Between your blog posts (for example, after the 2nd paragraph).
- Below your blog posts.
Here is an example of how to place AdSense Ads in a WordPress widget
The steps to follow:
- Login to your AdSense account and click ‘By Ad Units’ under the ‘Ads’ menu.
- Select the Ad format you want (Display Ads are recommended).
- Choose the ad's orientation (square, horizontal, vertical).
- Provide a name for your ad unit.
- Choose the size (responsive is recommended).
- Click the Create button to get the code.
Login to WordPress and paste the code to a Text Widget on your sidebar.
You can now SAVE the widget, and in a few minutes, AdSense will start showing on your website.
Note: You can wrap the Adsense code in a <div>, set the width to 100%, and add other styling properties to make the ads look good (see the example above).
This is an example of Adsense Ads in the Sidebar.
Conclusion
If you find the manual way confusing, then go with the first option and use the official Google AdSense plugin to add the ads to your WordPress blog.
Either way, it’s always recommended to enable Auto-Ads so that your ads will show properly on your desktop and mobile websites.
In case something is not clear, let me know in the comments.