How to add ads to WordPress

Are you looking to integrate into your ad stack? In this tutorial, we’ll look at how to successfully implement into WordPress to add more demand sources and increase your revenue from display ads with as little hassle as possible.

We will focus on navigating the UI to create ad units and integrate them with Advanced Ads.

Before we start, let us introduce you to if you haven’t heard about it before. is one of the top 5 ad tech companies worldwide and offers a large supply of display ads across search, native, display, mobile, local, products, and video. It also provides ad optimization capabilities and one unique ad format, called display-to-search (D2S). This ad format leverages search keywords and serves search ads bought by advertisers on a CPC-base, driving higher returns for you as a publisher.

Like all platforms, the technology used by evolves quickly and continuously. Also, do note that certain features might be in beta (And therefore might be under testing) or deprecated at some point. If you find that this tutorial needs an update, please let me know via this page.

Benefits of using Advanced Ads to place ads on your WordPress site

Before we get into the step-by-step walk-through of how to integrate with Advanced ads, let us spend a moment to consider the benefits of doing so. You could, after all, integrate manually or using their plugin as well.

Higher revenue opportunities through various display networks

When you use Advanced Ads, you’re never limited to one ad network only. Instead, you can both rotate and test several ad networks against each other at the same time, thereby maximizing revenue.

The truth is, most ad networks capture one piece of the market, but not another. By placing ads from one ad network manually or with a dedicated plugin provided by that ad network on your site, you’re essentially constraining your demand for a given placement to the requests which that particular network can supply.

Not so with Advanced Ads. Thanks to placements, you can create as many ads as you’d like for each network you’re working with and rotate ads or even groups of ads within one placement.

You can also set up weighted rotations. They allow you to balance how much traffic you end up sending to one particular network. As pointed out below, works excellent for the UK, Canadian, and US markets. But what if your site has a 30%-70% split of the UK vs. Dutch traffic? You’d still want to leverage, as it can increase your revenue but without devoting an entire placement to it.

Use placements in Advanced Ads and ensure that your ads rotate against targeted ads from some other network or your direct-sold ads, with a weight of 30%. That way, you’ll know you’re only sending 30% of your traffic to Of course, you’ll be able to optimize the rotation later based on your results.

Set up your ad units

We will start working on

If you do not already dispose of a account, you’ll have to sign up. Before you do so, you may want to check’s guidelines for admission to the program here

One requirement worth noting is that most of your traffic comes from the US, the UK, or Canada. These are also the markets for which they can provide the largest ad supply. Once you’ve applied, your application will take a couple of days to be reviewed. So be sure to factor in the extra time if working on a time-sensitive launch. 

Once approved, at login, you’ll end up on’s dashboard.

Dashboard after approval
Dashboard after approval

From there, you’re ready to head over to the “Ad units” tab and select “Add New”. However, keep in mind that you can paste your code only on an approved domain.

So, let’s imagine that you’re working with two sites, i.e., and Most likely, at the time of your application, you only submitted But now that you’ve gotten up and almost running, you want to create tags for both and Well, be warned: the tags won’t work on until also approved this second domain.

If this sounds like you, just go to the Sites tab, and hit “Add New” to add your new site. Do keep in mind that each site you add will have to go through a review process, as explained above.

How to create new ads
Create new ads

Next, you’ll be prompted to give your ad unit a name. Select a size and establish if the ad unit should be responsive. As usual, make sure to develop some rules of nomenclature.

For example, you could call this ad unit “media.net_mysiteaa_Adsize_Placement”. Descriptive titles are especially relevant if you’re working with a sizable number of ad networks, websites, and ad sizes.

Ad sizes recommends any of the following as their best-performing sizes:

  • 300×250 
  • 600×250 
  • 728×90 
  • Responsive Mobile Docked Unit 

Those might be suitable sizes to start with. But of course, you should weigh that against the design of your site. For more details, check out our Ad formats section below.

Create a new ad unit in

Note that the “Sticky Mobile Docked Unit” option is enabled by default. We recommend leaving that activated as it will allow you to run the same ad unit at the bottom of your mobile screen, much like you’re probably used to seeing on mobile apps.

If not, take a peek at the image below:

Sticky mobile docked unit from

Hit “Save” and get ready for the next step: getting the header code and pasting it into Advanced Ads.

Getting header and body tags

Once you hit save, you’ll be automatically directed to the “Get code” page, which also makes accessible from the Ad Units dashboard. The code is, as expected, unique for each ad unit. It can be rendered as “synchronous” or “asynchronous”.

As we suggest in this article on page speed, you should use “asynchronous” tags as much as possible. They load separately from your page content and therefore decrease latency. 

You’ll notice that the code consists of two parts: a header tag and a body tag. Both are necessary for optimal performance. Use the same option, synchronous or asynchronous, for both.

We’ll look first at how to implement the header tag, and later in the tutorial, on how to paste the body tag. Do keep in mind that if you were to paste the body tag on your site without its matching header tag, you’d probably end up with a blank space. Not pretty!

So, make sure your preferred option is selected, and then hit “Copy Code” next to the header tag.

Integrate codes in Advanced Ads

We have already published a comprehensive article on how to handle header codes in WordPress with Advanced Ads. It’s a worthy read, but for this tutorial, what’s essential to know is that you’ll need to have created in Advanced Ads at least one ad unit and one placement. To make both, follow these instructions.

Add the header tag 

  1. Go to Advanced Ads > Ads > New Ad.
  2. Select the ad type Plain text and code if it is not already pre-selected and insert the code which you have copied from
  3. Give your ad a title, e.g., “ Code”.
  4. Publish this ad and create a new placement for it.
  5. Go to Advanced Ads > Placements, choose the header code placement from the list, and select your ad unit.

Here’s how the header tag looks like when pasted inside my “Media.net_Header Code” ad unit. 

Copy the header tag into Advanced Ads

And below, you can see that same ad unit saved into my “Header Code” placement.

Note that I’ve chosen the header code placement type, which you can quickly tell apart thanks to its icon.

Placement for the header tag
Header code placement for the header tag

Place the body tag

Next, we can paste the “body tag” supplied by into one of my ad units, exactly where we want the actual ad to appear.

For example, suppose you want it to appear on your blog posts below the title but before the post content. In that case, you could assign the existing ad unit to a Before Content placement, or you add the Advanced Ads block to paste it there, as shown below.

Injecting an ad unit with the Advanced Ads block for Gutenberg
Injecting the ad unit manually with the Advanced Ads block

But let’s take it one step at a time.

It would be best if you still had your account opened. Copy your body tag code of the ad unit from the “Get code” tab, as shown in the image above.

To apply it to the ad unit of your choice within Advanced Ads, proceed as follows:

  1. Go to Advanced Ads > Ads > New ad.
  2. You can keep the Wizard enabled or click on Stop Wizard to see all options on the same page.
  3. Enter a title for the ad.
  4. Choose the Plain text and code ad type, as shown below.
Adding the body tag to WordPress
  1. When done, hit “Next”.
  2. Paste the ad code from, indicating the size you’ve chosen. In the example below, you’ll notice it’s 970×90.
Specifying the size of a ad
Specify the size of the ad
  1. Optionally, assign some visitor or display conditions. For example, you could add the “Specific Pages” condition to never show this ad on your contact page.    
  2. Select a placement where you want to display the ad, either existing or new, as shown below.
Placement for the body tag

At this point, your ad should be ready to appear! 

Next, we will look at how to integrate the ads.txt file from


Ads.txt is an initiative by the Interactive Advertising Bureau (IAB) which aims to protect publisher’s inventory from counterfeit by letting publishers add a piece of code to their sites to declare who is specifically approved to sell their inventory on their behalf. 

Simply put, there have been cases of websites being scraped in their entirety in an attempt to make money from digital advertising through 3rd party networks. 

The ads.txt code ensures that even though a website gets scraped, the duplicate version of it can’t be targeted by advertisers because it doesn’t include the correct ads.txt file.

Copy your ads.txt file from

Because of this, it is highly recommendable, as the next step in your setup, to copy your ads.txt file from and add it to your website. To do so, start by finding your “Ads.txt Settings” tab in your account. ads.txt settings
Ads.txt settings of

Once there, find the site you want to get your ads.txt file for and hit “Get status”.

Ads.txt settings of

This is what you’ll see:

Copy the code provided, which will include a series of strings like the following:, pub-1234567891234567, DIRECT, f12c34fec5672fa0, 12345, DIRECT, 1d23456b789f1ace, 000000, DIRECTCode language: CSS (css)

Please, never ever modify these strings.

Add the entries to your ads.txt from Advanced Ads

Next, go to Advanced Ads > Settings > General > Ads.txt and enter the file’s content below any existing code you had previously added. 

Add to the ads.txt

This is critical because, should you replace your previous code with the new one, you would prevent your other networks such as Adsense or the Moneytizer, or any others you’re working with from working as intended. When done, hit save.

Usually, if you implemented everything correctly, you should see an updated ads.txt status within a few days. Be patient because might take a few days to crawl the ads.txt file properly and give you a status update. If nothing has changed after one week, contact your account manager at and make sure to double-check that you’ve pasted the whole code. 

Find further insights on the ads.txt integration into Advanced Ads in the ads.txt manual.

Ad Formats offers, by default, a different kind of format than you might be familiar with, which they call “Two-Click Ads”. As hinted by the name, this format requires visitors of your blog to click twice on an ad for the click to be counted as such.

This format, on a green-themed website that deals with finances and saving, looks like this:

media-net two clicks ad format

Do note that the design is established by the publisher here, not by In other words, this is not just a Two-click ad. It’s a native two-click ad.

In size, it mimics a typical display ad format. Still, the advert itself leverages search intent (i.e., it’s keywords-driven) to generate relevant search terms that should answer the visitor’s question. You can it, therefore, match to campaigns targeting conversions.

Compare that with a standard display ad, which is generally used for branding and, therefore, leverages images’ power to target a broad number of users early on in the funnel.

Native, display, and contextual ads

While the Two-click-ad is the default format offered by, we recommend following the company’s prompt from their welcome e-mail. Ask for Native and Display ads, including video and mobile, to be enabled for your account as well. So that you can fully benefit from all of the formats they have to offer, and therefore drive higher revenue.

This means that to serve contextual ads, instead of search-based ads, you need to reach out to

AMP compatibility does support AMP (Accelerated Mobile Pages), both for its Two click ads and its header bidding solution. For specific information on the configuration, one option is to check out this article on GitHub and use that information when setting up the AMP ad using the “AMP” ad type in Advanced Ads (Responsive Ads add-on).

For particular support on setting up header bidding, the best bet is to contact your’s account manager, as recommends it in their FAQs. 


Possibly the most significant limitations refer to the limited country coverage, which we have highlighted a few times in this article.

But also keep currency concerns in mind. The network offers payments only in USD, making earnings susceptible to exchange rate fluctuations for publishers outside of the US. 

Troubleshooting and additional questions

As explained in the section on the Benefits of using Advanced Ads to integrate with WordPress, using our plugin allows you to run both Adsense and alongside each other, either in the same placement or as separate ad units.
Do keep in mind the recommendations about the ads.txt file above to ensure both networks can run seamlessly and efficiently.

As clarified by in their help center, you can implement their tag through a third-party ad server, such as Google Ad Manager, AppNexus, or OpenX.

To do so, you’d have to reach out to your account manager to get access to the implementation documentation. That integration does not affect your integration of Advanced ads with your ad server.

We recommend implementing networks in your ad server through a non-reserved campaign or line item priority type, such as network or price priority in Google Ad Manager or Remnant campaigns in OpenX. Using weights, CPC rates, or daily caps to limit the number of impressions sent to a number that can reasonably be filled by

For example, if has usually served 5,000 impressions daily, you should set the cap to either 4,500 or 5,500 impressions, and in no cases above that, to avoid blank impressions.

Considering that supplies inventory targeted to the Canadian, US, and UK markets, we recommend keeping that in mind when targeting your ad units through Advanced Ads in WordPress.

For example, suppose you have content in different languages. In that case, you could ensure to limit’s ad units to countries devoted to English-speaking visitors, for example, by leveraging the “browser language“ condition of Advanced Ads.

Remember that browser language is, of course, only a proxy for language. And if your site is in English and the language isn’t enough signal to identify users from those markets, you can use Geo-Targeting to limit the display of specific ad units only to visitors from selected countries.

To start, waiting some 15 minutes before declaring that an ad unit you’re running on your site is not working is always a best practice. The network might take a little bit to crawl your website at first and extract the information it needs to target ads appropriately.

But should your ads still fail to appear after an hour, there might be some hiccups that need fixing.

Here are a few recommended troubleshooting steps:

  • Can you display any other ads through Advanced ads? If not, check out this troubleshooting guide before proceeding to troubleshoot in
  • Is the site you’ve integrated with approved by Go to > Sites and check if the Status of the site says “Approved”.
  • Have you edited the code in any way? Double-check that the code isn’t missing any components. Or better yet, copy and paste it again in the ad unit you’ve created to run it in Advanced Ads. Verify that the code is correct both in the header and body code.
  • Have you added the header code to a “Head” placement as instructed and published the placement?
  • Where are you located physically? Given that serves ads targeted to the UK, the US, and Canada, you might want to use a VPN to visit your site from any of those locations and ensure that the ad appears correctly for visitors from those countries. Do consider the Geo-targeting add on to prevent to show blank ads to visitors from other countries. allows you to reuse the same ad unit several times on the same page and even on different websites. However, I don’t recommend this.

Using the same ad unit across several locations on your website will decrease your chances to optimize your performance in the long run. For example, you are making it hard to detect which ad units have low viewability or click-rates, as the reporting will be blended for all of the places where you’ve implemented the same ad code.

As long as you’re using synchronous or asynchronous tags consistently throughout your site, which we highly recommend, you do not need to paste the header tag for each ad unit.

In fact, the header tag looks the same, even across responsive vs. non-responsive ad units and across ad units of different sizes.

If you’re in doubt, cross-check your existing header code in diffchecker against one of the new ad units you’ve created. However, in 99% of cases, we expect the same header code to be valid and working across your entire site.


Stefania started her career in online marketing at Google in 2011, where, after a couple of years as a Google Ads specialist, she moved over to the Sales side, to support publishers small and large with their ad monetization strategy. Stefania speaks 5 languages fluently and is based on the Galician coast, where she enjoys hiking and writing.

Make it better

Increase your ad management skills without spending more time.
Join over 150,000 publishers and AdOpts increasing their ad revenue.