Ads.txt and AdSense: Complete Setup Guide to Protect Revenue in 2026
AdSense & Monetization

Ads.txt and AdSense: Complete Setup Guide to Protect Revenue in 2026

 Rahul Sharma  Oct 07, 2026  8  ~1,556 words

Ads.txt is a simple text file at yourdomain.com/ads.txt that publicly lists which ad networks are allowed to sell your ad inventory — and it's one of the easiest things you can do to protect your ad revenue. Ad fraud often works through domain spoofing: bad actors claim their junk inventory is actually your site's premium ad space, siphoning advertiser money away from real publishers like you. A correct ads.txt file lets buyers verify that a bid request claiming to be your site really is. Here's the complete setup, including AdSense.

What ads.txt actually does

The idea is borrowed from robots.txt. The IAB Tech Lab's ads.txt specification (current version 1.1) defines a plain-text file you publish at your domain root. Each line declares one authorized seller relationship: which ad system, which publisher ID, and whether the relationship is direct or through a reseller.

Programmatic ad buyers — demand-side platforms, ad exchanges — check your ads.txt before bidding. If a bid request claims to be selling inventory from your site but the seller isn't in your file, legitimate buyers walk away. That starves spoofed inventory of demand and keeps advertiser money flowing to real publishers. It doesn't eliminate all ad fraud, but it closes the easiest and most common hole.

Your complete ads.txt file

For a typical AdSense publisher, the file is short. Here's what it looks like:

# ads.txt for yourdomain.com
# Replace pub-XXXXXXXXXXXXXXXX with your own publisher ID

google.com, pub-XXXXXXXXXXXXXXXX, DIRECT, f08c47fec0942fa0

Each data line has three required fields and one optional field, separated by commas:

  1. Ad system domain — the domain of the advertising system, e.g. google.com.
  2. Publisher ID — your account identifier inside that system. For AdSense it starts with pub- followed by 16 digits.
  3. Relationship — exactly DIRECT or RESELLER (uppercase). DIRECT means you have a direct contract with the ad network; RESELLER means the network sells your inventory through an intermediary.
  4. Certification authority ID (optional) — for Google this is f08c47fec0942fa0, Google's TAG ID. Including it helps buyers verify the relationship through the Trustworthy Accountability Group registry.

Lines starting with # are comments and are ignored, so document what each line is for. If you work with additional networks — an ad exchange, a header-bidding partner — add one line per relationship, using the exact domain and ID each partner gives you. Generate the file with an ads.txt generator instead of hand-typing IDs, since a single wrong digit breaks the match.

Step-by-step: finding your AdSense publisher ID

  1. Log in to your Google AdSense account.
  2. Go to Account → Account information.
  3. Find your Publisher ID — it looks like pub-1234567890123456 (always starts with pub-).
  4. Copy it into your ads.txt file, replacing the placeholder, and save the file as ads.txt at your domain root: https://yourdomain.com/ads.txt.

Your ID is public information in this context — it already appears in your ad code. There's no security risk in publishing it in ads.txt; that's the entire point of the file.

DIRECT vs RESELLER: which one are you?

This is where most publisher files go wrong. Use DIRECT when you, the site owner, signed up with the ad network yourself — your AdSense account is always DIRECT. Use RESELLER when a third party (a monetization partner, an ad management service) sells your inventory through their own account with the network.

Why it matters: buyers pay more for DIRECT inventory because the chain is shorter and the fraud risk is lower. Mislabeling a reseller relationship as DIRECT doesn't get you higher bids — it gets your file flagged as inaccurate, which is worse than an honest RESELLER label.

Uploading and verifying

  1. Upload the file to your domain root so it loads at https://yourdomain.com/ads.txt. It must be plain text served as text/plain. On WordPress you can place it in your site's root directory via your hosting file manager; some SEO plugins can manage it too.
  2. Check both www and non-www. The file must be reachable on the domain version that serves your ads. Best practice: pick one canonical domain, 301-redirect the other to it (an .htaccess generator can write that redirect), and make sure ads.txt resolves there.
  3. Open it in a browser — you should see raw text, not a styled page or a 404. If your CMS renders a "page not found" template, the file isn't really there.
  4. Wait for AdSense to detect it. AdSense crawls your ads.txt periodically; detection and validation typically take up to a few days. In your AdSense account you'll see a status message about your ads.txt file — a warning there means something's wrong with the file or its location.

Common ads.txt mistakes

  • Typos in the publisher ID. One wrong digit and the line matches nothing. Copy-paste from AdSense, don't retype.
  • Wrong relationship label. Labeling a reseller as DIRECT (or vice versa) makes your file inaccurate.
  • File in the wrong place. yourdomain.com/files/ads.txt does nothing. It must be at the root.
  • HTML instead of plain text. Some page builders wrap the file in HTML. The crawler needs raw text.
  • Forgetting subdomains. If you serve ads on blog.yourdomain.com, that subdomain needs its own ads.txt (or the spec's SUBDOMAIN= variable declarations).
  • Leaving stale lines. Removed an ad partner last year? Remove their line. Stale entries let ex-partners keep selling inventory in your name.

A real-world multi-network example

Most publishers outgrow a single-network setup. Say you run AdSense plus a header-bidding partner and a direct deal through an SSP. Your file might look like this:

# ads.txt for yourdomain.com
# Last reviewed: 2026-10-07

# Google AdSense (direct account)
google.com, pub-1234567890123456, DIRECT, f08c47fec0942fa0

# Header bidding partner (their account, your inventory)
biddingpartner.com, 98765, RESELLER

# SSP for direct-sold campaigns
ssp-example.com, 54321, DIRECT

Every partner should give you their exact line — never invent one from a template. When you drop a partner, delete their line the same day; when you add one, verify the new file in a browser immediately. Once a year, email each partner and confirm the line is still correct — account IDs change during platform migrations more often than you'd think.

What ads.txt can't do

Be realistic about the limits. Ads.txt verifies who is authorized to sell your inventory — it doesn't verify that a specific ad impression actually happened on your site, and it can't stop invalid traffic or click fraud. Think of it as one layer: ads.txt for seller authorization, plus your ad network's fraud filters, plus monitoring your own traffic quality. Also note that ads.txt only helps with programmatic buyers that actually check it; direct-sold deals between you and an advertiser don't need it at all.

FAQ

Is ads.txt required for AdSense approval?

Not strictly required, but Google strongly recommends it and flags its absence in your account. For a new site applying to AdSense, having a correct ads.txt file in place signals you're a serious, professional publisher — and it costs you five minutes.

How long does AdSense take to detect my ads.txt?

Typically up to a few days after you publish the file. AdSense recrawls it periodically. If the warning persists beyond a week, re-check the file location, the plain-text format, and your publisher ID for typos.

Should I publish my publisher ID publicly? Isn't that a secret?

It's not a secret — your publisher ID is already embedded in every ad tag on your site, visible to anyone who views your page source. Publishing it in ads.txt is exactly how the system is designed to work.

What's the difference between ads.txt and sellers.json?

They're two halves of the same system. Your ads.txt (publisher side) declares which systems may sell your inventory. The ad system's sellers.json (exchange side) declares which publishers it represents. Buyers cross-check both. You only need to maintain ads.txt; the exchanges maintain sellers.json.

Do I need ads.txt on every subdomain?

The spec says publishers should post the file on the root domain "and any subdomains as needed." If a subdomain serves ads independently, give it its own file. If everything redirects to one canonical domain, one file there is enough.

Can ads.txt hurt my revenue?

Only if it's wrong. A correct file protects revenue by keeping spoofers away from your inventory. An incorrect file — wrong ID, wrong domain — can cause buyers to skip your legitimate inventory, so verify carefully after publishing.

Keep it fresh: the annual ads.txt audit

Set a yearly reminder. Open your ads.txt, and for every line ask: do we still work with this partner, is the account ID still correct, and is the DIRECT/RESELLER label still accurate? Partnerships end, platforms migrate accounts, and resellers become direct partners (or the reverse). A stale line doesn't just sit there harmlessly — it authorizes an ex-partner to keep selling inventory in your name. Five minutes a year keeps the file trustworthy.

The takeaway

Ads.txt is rare in SEO and monetization: a five-minute task with a real, lasting payoff. Publish the file, use your real publisher ID, label relationships honestly, verify it loads as plain text at your domain root, and audit it once a year. Buyers get the verification they need, spoofers lose their easiest trick, and your revenue goes to the inventory that actually earned it — yours.

Related Topics & Keywords

Share this article

Related Articles