Home » WordPress » How to integrate Google Adsense in WordPress

How to integrate Google Adsense in WordPress

There are lots of ways to monetize your popular website. You may use affiliate links, get sponsorships, sell products, offer memberships. But one of the easiest and most popular ways to make money from websites is Google ads. You just need some traffic, and Google Adsense will place ads on your website automatically.

Starting with Adsense is not hard. Your website needs to have at least 100 visitors a day, and needs to have lots of useful and unique content. You need to sign up to Google Adsense, add your website url, and wait for a week or two until Google (hopefully) approves the website.

If you’re wondering how to integrate Adsense code to WordPress your website is probably already approved. So you just need just a few more clicks to start making money! Here’s how you do it.

How to add Google Adsense in WordPress

First thing you need to do is to locate Adsense code that you’ll need to add to your WordPress website.

Best WordPress hosting 2024

Go to your Google Adsense account, and click Ads on the main menu. Select tab By site, and click on the Get code link.

add google adsense in wordpress

You’ll see a popup with general instructions and the actual script code you’ll need to place to your website.

google adsense code add to wordpress

Adsense code needs to be added in between <head></head> tags of your site.

There are multiple ways to add Adsense code or any other script to WordPress website’s <head> section. They all have their advantages and weaknesses.

  1. Add Adsense code directly to header.php file. It’s drawback – you’ll need to manually locate the <head> tag, and in some WordPress themes it might be tricky. We won’t cover it in this tutorial.
  2. Add Adsense code via WordPress theme’s functions.php file. It’s a better solution because WordPress will locate <head> tab, and will add a code to it automatically. It’s a great way to add the code if you’re using child theme.
    The drawback – this function might be lost if you’ll update your theme to the latest version while you’re not using a child theme.
  3. Add Adsense code to WordPress using a plugin.
    It’s a good solution because it does not depend on WordPress themes at all. But it still has a drawback – it’s an additional third-party plugin which needs to be maintained and updated.

Ok, let’s get straight to solutions.

How to add Google Adsense code in WordPress using functions.php

Go to Appearance >> Theme Editor in your WordPress website admin menu, and click on functions.php file. Add this code in the end of the file.

function integrate_adsense() {
	<script data-ad-client="ca-pub-168919073" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
add_action('wp_head', 'integrate_adsense');

It should look like this:

google adsense integration in wordpress manually

Now you have a correct function but you also need to replace the <script> code in the example with the code you previously opened in Google Adsense website.

After replacing the script Google Adsense will be integrated to your WordPress website. Just don’t forget to click Update file to make sure the changes are saved.

How to add Google Adsense in WordPress using plugin

To add Adsense code to WordPress using plugin go to your website’s admin panel and hit Plugins >> Add New in the main menu.

Enter head code into the search field at the top right of the page and look for Head & Footer Code plugin. Install and activate it.

add google adsense to wordpress using plugin

Once you activate plugin go to Tools >> Head & Footer Code, and add Google Adsense script code to HEAD Code field. Don’t forget to click Save Changes button at the bottom of the page.

add google adsense code in wordpress


After adding Adsense code to your WordPress website ads usually show up after an hour or two. It might take longer if you have very few visitors at the time.

One more tip. If you are using any caching plugins in your website, don’t forget to clear the cache after adding the Adsense code to make sure that it’s properly loaded.


Fathom analytics - privacy focused cookie-free website analytics

Most popular tutorials

Get our latest WordPress news and special offers from RockSolidWP!

Only useful WordPress and WooCommerce tips and tricks and exclusive offers for our readers once a month. No marketing nonsense.

Looking for reliable yet affordable WordPress hosting?
Hostinger is the way to go!

Get 10% OFF by using code IMAKEITWORK