How to Add Google AdSense to WordPress

Get HubSpot's WordPress Plugin
Jamie Juviler
Jamie Juviler


Are you looking to turn your WordPress website into a revenue-generating platform? Adding Google AdSense to your site is an excellent way to start earning money through online advertising.

woman adds google adsense to wordpress

In this beginner‘s guide, we’ll walk you through the simple steps of integrating Google AdSense into your WordPress site. No technical jargon, just straightforward instructions to get you started on the path to monetization.

Grow Your Business With HubSpot's Tools for WordPress Websites

Table of Contents

What is Google AdSense?

Google AdSense is a program that enables websites to display targeted advertisements to visitors. AdSense is free, easy to implement, and supports advertisements in the form of images, text, video, and interactive media.

AdSense is a hands-off approach to online advertising — you only need to worry about where to place the advertisements on your website and your webpages. Google handles everything else, including billing advertisers and determining which ads to display to your visitors.

Google AdSense monetizes on the pay-per-click (PPC) model, meaning advertisers pay only when someone clicks on their advertisement. The cost-per-click depends on keyword value, click through rate, and other factors. Revenue is split between the website publisher and Google — publishers take 68% of the revenue for every click. To learn more about the PPC structure, see our Ultimate Guide to PPC.

Advertisements displayed with Google AdSense are highly targeted. Google chooses relevant ads for visitors based on both the content of your website and Google’s ad personalization system, which tracks users’ interests based on browsing history.

Before we continue, note: There are also AdSense alternatives if you’re considering different platforms that might better suit your needs.

Ads and AdSense are two sides of the same coin, but it’s important to know the difference.

How to Add Google AdSense to WordPress

Now that we understand what makes AdSense useful, let’s learn how to link AdSense with WordPress. It’s a three-step process: registration, placing ads, and optimizing the layout of your ads.

Even before submitting your application, make sure that your WordPress site is up-to-date, free of security issues, and has enough original content to support advertisements.

1. Register for a Google AdSense account

To integrate AdSense with WordPress, you’ll first need to sign up for an AdSense account.

To get an account with Google AdSense:

  1. Go to the signup page and click Get Started, then follow the instructions to create your account with AdSense.
  2. After submitting your site information, you’ll see a page with some code.
  3. After placing Google’s code, return to your AdSense account, check the I’ve pasted the code onto my site box, and click Done.
  4. Google will review your application and respond within two weeks.

WordPress adsense plugins

Image Source

This code is pasted in the header of your website HTML pages and tells Google to display Google’s ads on these pages. To insert this code on your site, use a plugin like  Google’s Site Kit or Insert Headers and Footers. These plugins save you from having to edit the HTML directly.

If your site is approved, move on to the next step. If not, improve your site’s content volume and quality, update your plugins and WordPress core if needed, enhance your site’s security, then resubmit.

2. Place ads on your WordPress site

Google AdSense offers two methods for placing ads on your website. You can manually choose which pages and locations to put the ads, or you can let Google decide where to place them optimally. In this section, I’ll cover both of these methods.

How to Place Ads Manually

To manually put an ad on your site, we’ll first generate the code for an ad unit. An ad unit is a section of code that displays ads. You’ll want to create different ad units for different locations on your page (i.e. a sidebar ad versus a banner ad) since they’ll differ in type, shape, and behavior.

To generate your ad unit code:
  1. In your AdSense account, select Ads > Overview.
  2. Choose the By ad unit tab.
  3. Under Create new ad unit, select Display ads. Display ads are designed to show in areas of your site outside of your content, including headers, footers, and the sidebar. Alternatively, you can choose one of the other two options:
    • In-feed ads appear between links to articles/posts in an editorial feed or news feed.
    • In-article ads appear inside the content of your posts, like between paragraphs in a blog post.
  4. Name your new ad unit. This name won’t be seen by visitors and should help you keep track of its purpose (for example, “sidebar-square-1”).
  5. On the same page, and choose the shape and size of your ad unit. For size, choose responsive over static so your ads display properly on mobile.
  6. Click Create.
  7. Copy the code for this ad unit and save it somewhere you can access later.

Now comes the actual placement. You can put ads just about anywhere on your site’s pages and posts.

To place your new ad unit:
  1. From your WordPress dashboard, select Appearance > Widgets.
  2. Click-and-drag the Custom HTML widget into the area you want to display the ad, like the footer or sidebar.
  3. In the Content window that appears, paste the ad unit code you saved earlier and click Save.
  4. You can now view the new ad on your WordPress site.

How to Place Ads With Auto Ads

Google’s auto ads feature is an alternative to choosing ad placement yourself. With auto ads, Google scans your website pages and automatically places ads where they’re likely to be most profitable.

To get started with auto ads:
  1. In your AdSense account, select Ads > Overview.
  2. Choose the By site tab, then click Get code.
  3. Copy the AdSense code and use a plugin like Google’s Site Kit or Insert Headers and Footers to paste it into all of your page’s headers.

3. Adjust the layout of your ads

Be sure to put time into the look of your ad displays. Ads should mesh with the rest of your site and enhance the user experience, rather than disrupt with a buggy appearance. Consider trying an AdSense-friendly WordPress plugin to help you toggle ad positioning and look. Popular options include Advanced Ads, AdSanity, and Ad Inserter.

Alongside a plugin, you might also want to experiment with an AdSense-optimized WordPress theme. These themes are designed specifically with ad displays in mind, and make changing the appearance of your ads a bit easier.

Tips for Getting Started with Google Adsense

tips for getting started with Google AdSense

Image Source

Here are some beginner-friendly tips to help you make the most of using Google AdSense on your WordPress site:

1. Quality content is key.

I know you want to run ads. However, before you even consider making money from advertising, you need to make sure you have valuable content. Whatever your offering — whether that be blog posts, course content, or videos — needs to be valuable.

Great content attracts visitors, which increases your ad revenue. Google Adsense will reward you for the high-quality work that brings in engaged users.

2. Start with relevant ads.

Choose ad types that are closely related to your website‘s niche. This improves the chances of displaying ads that resonate with your audience, leading to higher click-through rates (CTR) and potentially more revenue. Google AdSense’s targeting algorithms work best when they have a clear understanding of your site's content.

3. Placement matters.

Experiment with different ad placements to find what works best for your audience. Commonly, ads placed above the fold (visible without scrolling) and within content tend to perform well. However, make sure not to overwhelm your readers with too many ads, as it could negatively affect user experience.

4. Prioritize a responsive, mobile-friendly design.

Ensure your WordPress theme is responsive and mobile-friendly. A significant portion of internet traffic comes from mobile devices. Google rewards mobile-friendly sites with better search rankings and ad optimization, which could lead to improved AdSense performance.

5. Optimize for page speed.

Slow-loading pages can deter visitors and impact your ad revenue. Use tools like Google PageSpeed Insights to identify areas for improvement. Faster loading times not only enhance user experience but can also positively influence ad viewability and user engagement.

6. A/B testing ad formats.

Sometimes small tweaks make a big difference. However, to know what exactly what works best you’ll need tor run experiments. That’s where A/B testing comes in. Here, you test one variation of an ad with a set audience. You make tweaks to a second version and run it with a different audience. From there, you see what performs best.

You can A/B test for different ad formats, corlors, and placements. Your results can help you determine which combination generates the highest earnings.

7. Monitor performance regularly.

You want your money to actually make an impact. That’s why you need to regularly review your AdSense performance reports. Metrics can help you see in which areas you are performing well and where you’ll need to make changes move forward.

Pay attention to metrics like CTR, RPM (Revenue per Mille), and eCPM (effective Cost Per Mille). You can more easily determine if your strategy has the desired ROI from tracking these metrics.

8. Comply with AdSense policies.

We know reading technical documents and community guidelines can feel tedious. However, you need to familiarize yourself with Google AdSense policies to ensure compliance. Violations could lead to penalties. You may even have your AdSense account suspended.

Understanding the rules and guidelines will help you maintain a positive and sustainable ad revenue stream.

9. Engage with Google Analytics.

This step may take a few minutes, but it’s well worth the time. Integrate Google Analytics with your WordPress site to gain deeper insights into your audience's behavior. You’ll be able to see what content attracts visiors and which pages are the most popular for ad placements.

With this information, you’ll know what you should double down on and what to leave behind.

How to Add Adsense Auto-ads Code to Wordpress

Adding AdSense Auto-ads code to your WordPress website is a straightforward process. Auto-ads allow Google to automatically place ads on your site where they are likely to perform well. Here's a step-by-step guide to help you with the process:

1. Login to your AdSense account.

Log in to your Google AdSense account. Be sure to use the same profile you used to create your AdSense account.

2. Access your AdSense code.

After logging in, click on “Ads” in the left sidebar. Then, click on “Overview” or “By ad unit” depending on the version of AdSense you're using. Next, click on “Get code” for the Auto-ads option.

2. Customize your auto-ads.

On the Auto-ads setup page, you‘ll be able to customize the types of ads you want to display. You can choose ad formats, like text ads, display ads, and in-article ads. Select the options that align with your website’s design and user experience preferences.

3. Generate the auto-ads code.

After customizing your Auto-ads settings, click the “Save” button to generate the Auto-ads code. Google will provide you with a code snippet that you need to add to your WordPress website.

4. Copy the auto-ads code.

Click the “Copy code” button to copy the Auto-ads code snippet to your clipboard. This code contains instructions for Google to automatically place ads on your website.

5. Log in to your WordPress dashboard

Open a new browser tab and log in to your WordPress dashboard.

Install and Activate a Header/Footer Code Plugin (Optional)

If you prefer not to manually edit your theme files, you can use a plugin to insert the code. Search for and install a plugin like “Header and Footer Scripts” or “Insert Headers and Footers.” Once installed, activate the plugin.

6. Add the auto-ads code using a plugin

If you‘re using a header/footer code plugin, navigate to the plugin’s settings in your WordPress dashboard. Paste the Auto-ads code snippet into the appropriate field (header or footer), depending on your preference. Save your changes.

7. Manually add the auto-ads code (alternative)

If you‘d rather not use a plugin, you can manually add the Auto-ads code to your theme’s header. To do this, go to your WordPress dashboard, navigate to “Appearance” > “Theme Editor,” and locate the header.php file. Paste the Auto-ads code just before the closing </head> tag. Remember to save your changes.

8. Verify the implementation

After adding the Auto-ads code, return to your AdSense account and click “Done” on the Auto-ads setup page. Google will start placing ads on your site based on your chosen settings. It might take a little time for ads to begin showing up.

Track ads on WordPress.

You’ve gotten ads up and running, but are they effective? When placing paid advertisements on your WordPress site, metrics are a must.

Fortunately, AdSense lets you track the performance of ad units with its channels feature. With channels, you can sort your ads by variables like page placement and ad size, and determine which tweaks will bring in more clicks. Learn how to use channels on Google’s support page.

Plugins are also your friend here. Options like MonsterInsights, ExactMetrics, and many other WordPress analytics tools report traffic to your pages. Consider enabling Adsense on your high-performing pages to get the most eyes on your ads.

By following these steps, your WordPress website will gain an additional revenue stream that you can invest back into your business and website costs. Focus on growing your brand and refining your WordPress site, and let Google Adsense work for you.

Editor's note: This post was originally published in June 2020 and has been updated for comprehensiveness.

Use HubSpot tools on your WordPress website and connect the two platforms  without dealing with code. Click here to learn more.

Related Articles


Capture, organize, and engage web visitors with free forms, live chat, CRM, analytics, and more.


CMS Hub is flexible for marketers, powerful for developers, and gives customers a personalized, secure experience