Adjet

How to Set Up ads.txt in WordPress (AdSense Guide)

Trying to set up ads.txt in WordPress because AdSense suddenly started warning you about “Earnings at risk”? Here's the complete guide: what the file actually is, how a line is structured, which setup method actually holds up, and which mistakes cost you the most money.

Most people who want to set up ads.txt in WordPress arrive here the same way: a glance at their AdSense account, and there it is, the notorious “Earnings at risk” warning. Don't panic – that's not a ban from the program, it's a sign that your domain is missing a valid ads.txt file, or that the one it has is broken. This post explains what the file actually does, how a line is structured, which setup paths exist in WordPress, and how you can verify at the end that everything actually checks out. This is a focused, detailed look at ads.txt specifically, not a full AdSense walkthrough.

What Is an ads.txt File?

ads.txt stands for “Authorized Digital Sellers” and is an open standard from the IAB Tech Lab, the trade body representing the digital advertising industry. The idea is simple: a plain text file in your domain's root directory lists which ad networks and vendors are authorized to sell ad inventory on that exact website. Advertisers and their systems can automatically check, before every bid, whether the seller currently offering them a placement on your site is actually authorized to do so.

The standard exists because of ad fraud in the form of domain spoofing: fraudsters claim to be selling inventory on well-known, reputable domains they have nothing to do with. Ad budget then flows to fraudsters instead of real site owners, and advertisers pay for impressions that were never actually served on the domain they thought they were buying. A correctly maintained ads.txt makes that trick worthless for your domain, because anyone checking can immediately see which sellers are genuinely authorized and ignore everyone else.

Why Does AdSense Require ads.txt? The “Earnings at Risk” Warning Explained

Google AdSense was one of the first major networks to enforce ads.txt consistently, and that's exactly where the warning most people first encounter it comes from. If your AdSense account shows a message like “Earnings at risk,” it means Google couldn't find a valid ads.txt file on your domain listing your publisher ID as an authorized seller.

The consequences build up gradually rather than hitting all at once, but they're not something to ignore either. First, bids tend to drop, because a growing number of demand-side platforms and programmatic buyers are configured to skip bidding entirely, or bid lower, on domains without a valid ads.txt. If the situation persists for a while, Google can further restrict ad delivery on the affected domain. The good news: the fix is usually simple – you just need the right line in the right place, and the warning clears itself after Google's next check.

Anatomy of an ads.txt Line: Domain, Publisher ID, Relationship Type, TAG ID

Every line in an ads.txt file follows the same pattern of four comma-separated fields. A typical AdSense line looks like this:

google.com, pub-XXXXXXXXXXXXXXXX, DIRECT, f08c47fec0942fa0

The four fields, in detail:

  • Ad network domain: Always google.com for AdSense. If you work with several networks, each has its own domain and therefore its own line.
  • Publisher ID: Your individual identifier within that network, in the AdSense case in the format pub- followed by a 16-digit number. You'll find it in your AdSense account under Account, usually right in the ads.txt recommendation Google shows you.
  • Relationship type, DIRECT or RESELLER: DIRECT means you, the site owner, sell your ad inventory directly to that network, which is the standard case for AdSense. RESELLER means an intermediary is authorized to resell your inventory on your behalf, for example if you go through an ad rep or a network partner program.
  • TAG ID, optional: A certification ID for the network, which for AdSense is the fixed value f08c47fec0942fa0. It's technically optional but recommended, since it further confirms your domain actually belongs to Google rather than just claiming to work with them.

If you're running additional ad networks alongside AdSense, say through Adjet or another ad management tool, each network needs its own line with its own publisher ID. The file simply grows line by line, one line per network and relationship, nothing more is required.

Setting Up ads.txt in WordPress: An Honest Comparison

There are essentially three ways to get the file in place on WordPress. All three work, they just suit different situations and different levels of technical access.

Manually via FTP into the Root Directory (the Cleanest Way)

The most direct and reliable route is uploading via FTP or your host's file manager, because the file then sits exactly where crawlers expect it, independent of WordPress, themes, or plugins. Here's how:

  1. Open an FTP client or the file manager in your hosting control panel and connect to your web space.
  2. Navigate to your domain's root directory, usually public_html, www, or a folder named after your domain, depending on your host. Important: this is the same folder that holds your WordPress installation's wp-config.php, not a subfolder like /wp-content/.
  3. Create a plain text file locally named ads.txt, with no formatting at all – a basic text editor rather than Word or similar programs is best.
  4. Enter the line or lines for your ad networks, one line per network, each with domain, publisher ID, relationship type, and an optional TAG ID.
  5. Upload the file to the root directory and then check directly in your browser that it's reachable.

This route survives theme changes, plugin updates, and WordPress updates equally well, because the file exists completely independently of the CMS. The only downside: you need FTP access or access to your host's file manager.

Via a Plugin

If you don't have FTP access, or several people work on the site without everyone needing server access, a plugin can serve the file virtually, usually through a WordPress rule that intercepts requests to /ads.txt and outputs the stored content. That's convenient and quick to manage from the backend, but it has a catch: if the rule stops working for any reason, say after a plugin conflict or a broken permalink setting, the file disappears without an obvious cause, and you often only notice once the AdSense warning reappears.

Through Your Host

Some hosting control panels offer their own interface for editing root-directory files directly in the browser, without a separate FTP client. Technically that's the same route as the manual FTP method, just with a more convenient interface. Where it's available, it's a good alternative if you'd rather not install an FTP client.

Honestly, the manual FTP or file-manager route remains the most robust, because it works completely independently of WordPress. A plugin is the pragmatic solution when FTP access is missing, but it shouldn't be forgotten afterward – check on it regularly.

Verifying ads.txt Is Actually Reachable

After setting it up, it's always worth doing a plain-text check: open yourdomain.com/ads.txt directly in your browser. You should see the file's raw text, no 404 error, no redirect to the homepage, and no HTML page wrapped around it. Check both the www. and non-www versions, as well as https://, since that's exactly where most of the mistakes covered in the next section happen.

Fixing ads.txt Errors: The Most Common Pitfalls

A handful of mistakes show up again and again during setup, usually unnoticed until AdSense reporting comes in weaker than expected.

  • File in the wrong directory: ads.txt sits in a subfolder instead of the real root directory, for example accidentally in /wp-content/ or a backup folder. It has to be reachable at exactly yourdomain.com/ads.txt, no level deeper.
  • Subdomain issues: If your ads run on a subdomain, say blog.yourdomain.com, that subdomain may need its own ads.txt, depending on how the specific ad network runs its check. Don't blindly assume the main domain automatically covers it.
  • Forgotten www or non-www version: If your site is only correctly set up under one of the two variants while crawlers request the other, the file can be treated as missing. Check both variants and set up a clean redirect if you're unsure.
  • Caching serves an old version: A caching plugin or a CDN in front of your site can serve a stale copy of the file even though you've long since added a new line. Purge the cache specifically for /ads.txt after making changes.
  • Missing additional networks: If you run other ad networks alongside AdSense, say through an ad management plugin, each one needs its own line added. An incomplete list means only some of your sellers are recognized as authorized.
  • Typos in the publisher ID: A single wrong character in the long pub- number is enough to make the line worthless to AdSense. Copy the ID directly from your AdSense account rather than typing it by hand.

How Long Does It Take AdSense to Recognize ads.txt?

Google crawls domains regularly for valid ads.txt files, but not in real time. After uploading or updating the file, it can take anywhere from a few hours to a few days, depending on the domain, before the “Earnings at risk” message disappears from your AdSense account. Impatience doesn't help here – re-uploading the same correct file doesn't speed up detection. It's more useful to spend the waiting time double-checking that the file is genuinely reachable at the right URL and that the publisher ID is exactly right.

app-ads.txt in Brief

Alongside ads.txt there's a counterpart, app-ads.txt, which serves the same purpose for mobile apps instead of websites. If you also run your own app with its own ad inventory in app stores, in addition to your WordPress site, you need a separate app-ads.txt on the domain listed as the developer website in your app-store metadata. For a plain WordPress website without an accompanying app, app-ads.txt isn't relevant, and you can safely ignore this point.

Where Adjet Fits In

Adjet manages your ads directly, with its own AdSense wizard for publisher and slot ID, targeted placement, and local statistics right in the WordPress backend. ads.txt belongs to the basic AdSense setup regardless of which ad tool you use – it's not a feature an ad plugin handles for you, it's a one-time step at the server level that has to be done independently of the ad tool you choose.

Conclusion: A Small File With a Big Impact

Setting up ads.txt in WordPress isn't technically a big deal – a single text file with a handful of lines in the root directory is usually enough. The real work is getting the line structured correctly, placing the file in the right spot, and then actually verifying it's reachable instead of trusting a plugin or a guess. Know the common mistakes – wrong directory, a forgotten subdomain, www/non-www mismatches, caching, and typos in the publisher ID – and you avoid both the “Earnings at risk” warning and the lost revenue that comes with it. You'll find more on our plugin pricing, including Adjet, on our pricing page.

Manage your ads centrally with Adjet

Adjet comes with its own AdSense wizard, controls placement centrally, and shows clicks and impressions locally in your WordPress backend. ads.txt is a one-time server-level setup you still handle separately.

See Adjet

Frequently Asked Questions About ads.txt in WordPress

Where does ads.txt need to live?

Your ads.txt file must live in your domain's root directory and be reachable at exactly yourdomain.com/ads.txt, not in a subfolder like /wp-content/ or /blog/. In WordPress, that's the same folder as your wp-config.php, usually public_html or www depending on your host. If you're uploading via FTP, make sure you navigate straight into that root directory rather than one level too deep.

What does the “Earnings at risk” warning mean?

The “Earnings at risk” warning appears in Google AdSense when it can't find a valid ads.txt file with your publisher ID on your domain. It doesn't mean an immediate ban, but it does tend to mean lower bids, since many demand platforms won't bid at all on domains without a valid ads.txt. Once you've set up the file correctly, the warning disappears the next time Google re-crawls your domain.

Do I need a separate line for every ad network?

Yes, every ad network needs its own line with its own publisher ID, even if several networks are serving ads on your site at the same time. If you're running AdSense alongside another network, you simply add a second line with that network's domain and ID. An incomplete list means only some of your sellers are recognized as authorized, while the rest are still flagged as a risk.

How long does it take Google to recognize ads.txt?

It usually takes anywhere from a few hours to a few days for Google to re-crawl your domain and register an updated ads.txt file. Re-uploading the same correct file doesn't speed this up. It's more useful to spend the waiting time double-checking that the file is actually reachable at the right URL and that your publisher ID is exactly right.

Do I also need an app-ads.txt?

Only if you're running a mobile app with its own ad inventory alongside your WordPress site. app-ads.txt is the app-store equivalent of ads.txt and needs to live on the domain listed as the developer website in your app-store metadata. For a plain website without an accompanying app, app-ads.txt isn't relevant and can be ignored.

Back to the blog A hafenstudios post