Learn how to add Google AdSense to your WordPress website in an easy way and fully set it up for better usage, control, and results.
In this tutorial, you will learn:
- How to verify your website in your AdSense account.
- How to activate Site Authorization to prevent abuse of your AdSense code by sites that don’t belong to you.
- How to add automatic placement of AdSense ads for mobile and desktop visitors (called Page-level ads).
- How to test AdSense Page-level ads.
To follow along, please be certain that you have an approved AdSense account, and that you have the proper Privacy and Cookie Policy information in place on your website, as per the Google AdSense policies.
First, let’s verify your site. This is a required step if wanting to use the QuickStart feature. QuickStart allows for the automatic, intelligent, placement of AdSense ads for mobile and desktop visitors to your website.
- To verify your website, within your Google AdSense account, click on Settings, then click My Sites.
- Click the Plus button.
- Type in your website address in the box.
- Click Add Site to use Google AdSense in WordPress.
At this point, you may want to set it up so that *only* your authorized sites can display your AdSense.
Sometimes what happens is, that another site will scrape the content of your website, including your AdSense code, and then add that content to their site.
If that happens, and that site violates any google ads policies, it’s you that can be affected by it. This step just prevents you from wishing you had done it sooner if down the line something like this happens.
To set up Site AdSense Authorization: Add Google AdSense to WordPress
- In the Manage Sites area, click the 3 stacked dots on the right side of the page.
- Click on Site Authorization.
- Turn it on, and click Save.
Now, let’s activate the auto-placement of ads on your website.
To turn on this feature:
- In your AdSense account, go to My Ads, then Page-level Ads.
- Turn on one or both of the Anchor/overlay ads and Vignette ads, by sliding the sliders.
- Open your WordPress Dashboard in a new Tab or Window.
The next step is to get the needed code for your website to finalize the setup.
Worth noting though, that this code is the same code that newer google ads users would have needed to add to their websites during the application process. So, you may already have it in place and can skip to the Testing section.
Long-time users of google ads did not need to place this code when applying, so these steps will be required.
Also, worth mentioning, is that this exact same code can be used on all pages of all your sites.
For this next step, we are going to create a quick plugin to place the AdSense code on all pages of your WordPress website.
I find that it’s extremely easy and fast to set up a plugin using the Pluginception plugin, so let’s get that installed first.
To install Pluginception, follow these steps:
- From within your WordPress Dashboard, click on Plugins, then click Add New.
- In the search box, type Pluginception.
- Click Install Now.
- Click Activate. This will open up a new option within the Plugins menu called Create a New Plugin.
Follow these steps to create your custom plugin:
- Firstly, click the Create a New Plugin link.
- Secondly, live the plugin a name such as My Google AdSense Placement Plugin.
- Click the Create a Blank Plugin button.
- Now, add the code into your plugin that you see in the video, or below these steps, if you are following along with the written tutorial.
- Switch back to add Google AdSense to WordPress.
- Click the Get Code button.
- Copy the code to the Clipboard.
- Replace where it says YOUR ADSENSE CODE with the code copied from AdSense in the previous step.
- Finally, click the Update File button.
There are two ways to test your work. Let’s do both right now.
- Firstly, visit your website from your Desktop or Laptop computer.
- Secondly, right-click anywhere on the page and click View Source.
- Look for the code that you inserted. You can do a find, usually by pressing Ctrl+F and typing adsbygoogle as one word with no spaces.
- Now, let’s have a look to see if the ads show on Mobile. Open up a page on your website with a high-end mobile device in Portrait view (as opposed to Landscape view). Add #googleads to the end of the URL.
- Select the ad format that you want to test, then check the results on your device.
- Finally, for vignettes, click any of the highlighted links on your page to test whether the ads are working.
If you are having problems displaying ads during testing, be sure to visit Google’s Guide to testing Page-level ads to see why that may be. Do a Google search for “Guide to testing Page-level ads” to find the page.
Code used within this tutorial: Add Google AdSense to WordPress
function my_google_adsense_placement_function() { $output='YOUR ADSENSE CODE'; echo $output; } add_action('wp_head','my_google_adsense_placement_function');
All the Visualmodo WordPress themes have a custom area for an easy code upload on their theme options in case you want to do it in another way however both ways will work perfectly.