How to Set Up ads.txt (and Fix “Earnings at Risk”)

ads.txt is a small text file that tells advertisers who is allowed to sell your ad space. Getting it wrong can quietly cost you revenue.

By Astrosmic Editorial Team · Published · 4 min read

Lines of code shown on a computer screen

ads.txt (Authorized Digital Sellers) is an industry standard from the IAB Tech Lab. It is a public list of the companies allowed to sell ad space on your site. Advertisers and ad exchanges check it to avoid buying fake or spoofed inventory, so a missing or incorrect file can mean fewer bids for your ads.

What an ads.txt line looks like

Each line describes one authorised seller, with up to four comma-separated fields:

google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0
  1. Ad system domain — the company selling the ads (here, google.com).
  2. Your publisher account ID with that company (for AdSense, your pub- ID).
  3. Relationship — DIRECT if you control the account, RESELLER if someone else sells on your behalf.
  4. Certification authority ID (optional) — the seller’s TAG ID. Google’s is f08c47fec0942fa0.

Lines starting with # are comments.

Step-by-step setup

  1. Find your publisher ID. In AdSense, open Account → Settings → Account information. It looks like pub-1234567890123456.
  2. Create a plain text file named exactly ads.txt and add your line. AdSense also offers a ready-made snippet on the Sites page.
  3. Upload it to your domain root so it loads at https://yourdomain.com/ads.txt. On WordPress, an ads.txt plugin can do this for you.
  4. Open the URL in your browser to confirm it loads as plain text without a redirect to a different domain.
  5. Wait for the crawl. AdSense rechecks the file over time; the Sites page shows its status.

Using this site’s code? Set ADSENSE_CLIENT in site.js and the server publishes a correct /ads.txt automatically.

ads.txt with managed ad networks

Managed networks such as Mediavine and Raptive work with many ad partners, so their ads.txt files contain hundreds of lines that change often. They typically keep the file up to date for you, either through a plugin or by having you redirect your ads.txt to a file they host. Follow your network’s instructions exactly and do not edit their lines by hand.

Common mistakes

  • Wrong location. The file must be at the root of the domain, not in /blog/ads.txt or a subfolder.
  • Typos in the publisher ID. One wrong digit makes the line useless.
  • Formatting the file in a word processor. Use a plain text editor so no hidden formatting is added.
  • Removing old lines when switching networks before the new setup is live, or leaving outdated lines for networks you no longer use.
  • Subdomains. ads.txt applies to the root domain. If you serve ads on a subdomain, declare it in the root file with a subdomain= line as described in the standard.

What about apps?

Mobile apps use a sister standard called app-ads.txt. It is hosted on the developer website listed in your app store listing. Networks such as AdMob check it in the same way. See our mobile app ad networks guide.

Colorful JavaScript code on a monitor

Checking your ads.txt is working

  • Visit https://yourdomain.com/ads.txt in a browser and confirm the file appears as plain text.
  • Check that both http and https, and both the www and non-www versions of your domain, either serve the file or redirect to the version that does.
  • In AdSense, open the Sites page and look at the ads.txt status for your domain.
  • Use an online ads.txt validator to catch formatting errors.

What sellers.json has to do with it

ads.txt is published by you, the seller. Its counterpart, sellers.json, is published by ad systems and lists the publishers and intermediaries they work with. Together, they let buyers trace the path from advertiser to publisher and confirm each step is authorised. You do not need to create a sellers.json file as a publisher, but this is why accurate account IDs matter: buyers match the IDs in your ads.txt against the ad system’s sellers.json.

Keeping ads.txt up to date

Review your ads.txt whenever you add or remove an ad partner. Outdated lines for networks you no longer use are not usually harmful, but they create clutter and can confuse audits. Missing lines for partners you do use can cost revenue, because buyers that verify ads.txt may refuse to bid on unauthorised inventory. If you use a managed network, let it manage the file and only add lines your network approves.

Example ads.txt files

A small site using only AdSense needs a single line:

# ads.txt for example.com
google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0

A site using AdSense plus another network would add that network’s lines below, exactly as the network provides them. A site on a managed network may have hundreds of lines, which the network maintains. Whatever your setup, the rule is the same: every company selling your inventory should be listed, with the correct account ID and relationship.

Key takeaways

  • ads.txt lists every company authorised to sell your ad space.
  • It must live at the root of your domain.
  • Each line needs the correct ad system, account ID and relationship.
  • Managed networks usually maintain the file for you.

Frequently asked questions

Is ads.txt required for AdSense?

Google strongly recommends it, and AdSense shows an "earnings at risk" warning when your ads.txt file is missing or does not include your publisher ID. Without it, some advertisers may not buy your inventory.

Where do I put the ads.txt file?

At the root of your domain, so that it loads at https://yourdomain.com/ads.txt. It must be a plain text file served over HTTP or HTTPS, not inside a folder.

How long does it take Google to see my ads.txt?

Crawlers re-check ads.txt files periodically. It can take from a few days up to several weeks for the AdSense warning to disappear after you upload a correct file.

What does DIRECT vs RESELLER mean in ads.txt?

DIRECT means you, the publisher, directly control the account with that ad system. RESELLER means another company is authorised to sell your inventory through its own account, as managed networks often do.

Does ads.txt affect SEO?

No. ads.txt is read by advertising systems, not used as a search ranking factor. It affects how buyers trust and bid on your ad inventory.

Do I need a separate ads.txt for each domain?

Yes. Each root domain you show ads on needs its own ads.txt file at its root. Subdomains can be covered from the root domain file using the subdomain= directive described in the IAB standard.