Google AdSense

How to Set Up and Fix ads.txt for AdSense on WordPress

A plain text ads.txt file open in a browser next to a WordPress dashboard

This guide is for bloggers and small site owners who run Google AdSense on WordPress and have seen an ads.txt warning in their account. It explains what the file is, what goes in it, where it has to live, how to create it, and how to work through the “Not found” and “Unauthorized” statuses. The details come from Google’s AdSense Help Center and the IAB Tech Lab’s ads.txt page, and anything that does not come from those pages is labelled as such.

Contents
  1. What ads.txt is and why AdSense asks for it
  2. The exact line AdSense gives you
  3. Where the file must live
  4. How to create ads.txt on WordPress
    1. Step 1: copy the line from AdSense
    2. Step 2: put the line in a plain text file
    3. Step 3: upload it to the root
  5. How to check the file in your browser
  6. Fixing the status in AdSense
    1. If the status is "Not found"
    2. If the status is "Unauthorized"
    3. About the "Earnings at risk" alert
    4. Ask AdSense to recheck, and expect a delay
  7. Common mistakes
  8. Key takeaways
  9. FAQ
    1. Is ads.txt required for AdSense?
    2. Can I create ads.txt as a WordPress page?
    3. Why does AdSense still show an error after I fixed the file?
    4. Do I need to remove other networks' lines?
  10. Sources

What ads.txt is and why AdSense asks for it

Ads.txt stands for “Authorized Digital Sellers”. The IAB Tech Lab, which maintains the standard, describes it as a way for publishers and distributors to publicly declare the companies they authorize to sell their digital inventory. The stated aim is more transparency in programmatic advertising: buyers can check a public record to see who is allowed to sell a publisher’s ad space, which makes it harder for bad actors to sell counterfeit inventory.

For you as a publisher, that means a small text file on your own domain that lists the ad companies you work with. Google’s AdSense Help page says that using ads.txt is “not mandatory, but it’s highly recommended”. It also says an ads.txt problem produces an alert in your AdSense account that you should fix promptly to avoid an impact on revenue.

Advertisement

The IAB Tech Lab page lists Ads.txt 1.1 (released August 2022) as the current version, which added the OWNERDOMAIN and MANAGERDOMAIN variables. This guide sticks to the standard AdSense line.

Enjoying this? Get our best tips by email

Practical SEO, link building and content strategies, straight to your inbox.

No spam. Unsubscribe any time.

The exact line AdSense gives you

Google’s help page shows the AdSense entry in this form, with a placeholder where your own publisher ID goes:

google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0

Reading the example, the line has four comma-separated parts: the ad system’s domain (google.com), your publisher ID (the “pub-” number), the relationship (DIRECT), and a certification authority ID. Google’s page does not label the fields, so treat that breakdown as a reading of the example rather than a quotation from the specification.

Do not type the line from memory or copy it from another site. Your publisher ID is unique to your account. Copy the line from inside AdSense instead (steps below). If you also use another ad network, you add that network’s own line to the same file, and Google says to contact that network for its information.

Where the file must live

Google’s page says the file goes in your site’s root directory, meaning the folder directly after the top-level domain. Its example is example.com/ads.txt. It is not a page, a post, or something inside /wp-content/.

On most WordPress hosts, the root is the folder that holds wp-config.php and the wp-admin and wp-content folders. If WordPress sits in a subfolder, ask your host which folder the domain itself points to.

Advertisement

How to create ads.txt on WordPress

Step 1: copy the line from AdSense

  1. Sign in to AdSense.
  2. Click Fix now on the alert on your homepage, or click Sites and select the site showing the “Not found” or “Unauthorized” status.
  3. Choose the Ads.txt snippet option.
  4. Click Copy.

Step 2: put the line in a plain text file

Google’s instructions say to create a plain text (.txt) file in a plain text editor such as Notepad or TextEdit, paste the line in, and name the file ads.txt. Avoid word processors, which can add formatting characters.

Step 3: upload it to the root

There are two general routes on WordPress, and either works as long as the result is a file at the root of your domain.

MethodHow it worksTrade-offs
File manager or FTP/SFTPUpload ads.txt into the root folder through your host’s file manager or an FTP/SFTP client.Simple and has no plugin overhead. Needs hosting access, and you must edit the file by hand when you add networks.
A WordPress pluginA plugin that manages ads.txt lets you paste the lines into an editor in the WordPress dashboard and serves the file for you.Easier for non-technical owners. Adds another plugin to maintain, and behaviour differs between plugins, so read the plugin’s own documentation first.

This guide does not recommend a specific plugin, because the pages it relies on do not cover any. If you use one, check its WordPress.org listing for recent updates and compatibility, and make sure it does not conflict with a physical ads.txt file already on the server.

If you are comfortable with root-level text files, the process is similar to editing the robots.txt file. Our guide on how to view, edit and test robots.txt on WordPress covers the same kind of file-location questions.

How to check the file in your browser

Type your domain followed by /ads.txt into the address bar, for example example.com/ads.txt with your own domain. Google’s page says that if the file displays, AdSense will likely find it. You should see plain text and nothing else: no theme header, no menu, no 404 page.

Check that your publisher ID matches your AdSense account and that each entry sits on its own line. A styled WordPress page, a “page not found” message or an empty screen means the file is not served correctly.

Advertisement

Fixing the status in AdSense

Google’s pages describe these statuses for each site under Sites in AdSense:

StatusWhat it means in Google’s guideWhat to do
Not foundAdSense could not locate an ads.txt file on the site.Create the file with the Ads.txt snippet line and upload it to the root directory.
UnauthorizedA file exists, but your publisher ID is missing from it.Copy the line from your AdSense account and add it to each ads.txt file.
AuthorizedThe file is verified.Nothing. If the site is Ready and ads are set up, ads will start to show.

If the status is “Not found”

  • Open the URL in a browser. If you get a 404, the file is missing or in the wrong folder.
  • If the file loads in the browser but AdSense still says “Not found”, the status may simply not have refreshed yet (see timing below).

If the status is “Unauthorized”

  • Compare the publisher ID in the file with the one in your account, character by character.
  • Copy the line again with Sites, your site, then Copy, and paste it into the file.
  • Keep any lines for other networks. You are adding a line, not replacing the file’s other contents.

About the “Earnings at risk” alert

Publishers often search for “Earnings at risk” because that is the wording some of them report seeing in the account. The Google help pages opened for this article do not use that phrase. They describe an alert that appears when there is an ads.txt problem. Treat “Earnings at risk” as the label commonly reported by publishers, and use the site’s ads.txt status under Sites to see which of the two problems above you actually have. Google’s advice for either one is to fix it promptly to avoid revenue impact.

Ask AdSense to recheck, and expect a delay

After you fix the file, go to Sites, click the site, and click Check for updates to ask AdSense to recheck it. Google’s page says changes may take “a few days” to be reflected in AdSense, and that sites with few ad requests may take “up to a month”. Once the status shows Authorized, it says ads may take up to an hour to appear on your pages.

Common mistakes

  • Wrong location. Uploading to /wp-content/ or a subfolder instead of the root.
  • Typing the ID by hand. A single wrong digit means the Unauthorized status.
  • Overwriting other networks. Replacing the whole file when you only meant to add the AdSense line.
  • Creating the file twice. A physical file plus a plugin-generated one can confuse which version is served.

Ads.txt is one part of a healthy AdSense setup. If you are still earning your first approval, read our guide on getting AdSense approval with a blog, and for the revenue side see boosting your AdSense revenue.

Key takeaways

  • Ads.txt is a public plain-text list of the sellers you authorize. Google calls it not mandatory but highly recommended.
  • Copy your AdSense line from Sites and the Ads.txt snippet option rather than typing it.
  • The file must be at the root, such as example.com/ads.txt. If it displays in your browser there, AdSense will likely find it.
  • “Not found” means no file was located; “Unauthorized” means your publisher ID is missing from the file.
  • Use Check for updates after fixing, and allow a few days, or up to a month for low-traffic sites.

FAQ

Is ads.txt required for AdSense?

Google’s help page says it is not mandatory but is highly recommended. It also says an ads.txt issue triggers an alert in your account that should be fixed promptly to avoid an impact on revenue.

Can I create ads.txt as a WordPress page?

No. Google’s guidance is a plain text file in the root directory. A WordPress page would render with your theme’s HTML, not as plain text. Use a real file via file manager or FTP, or a plugin that serves the plain-text file at the root URL.

Why does AdSense still show an error after I fixed the file?

Updates are not instant. Google says changes may take a few days to show, and up to a month for sites with few ad requests. Confirm the file displays correctly in your browser, click Check for updates, and wait.

Do I need to remove other networks’ lines?

No. Google says to add other networks’ lines if you use them, getting each line from that network. The AdSense line sits alongside them in the same file.

Sources

Advertisement