How to Create and Verify an Ads.txt File for AdSense

laptop computer on glass-top table
Photo by Carlos Muza on Unsplash

What You Will Learn

  • An ads.txt file is a public plain-text document hosted at your root domain that lists authorized sellers of your ad space.
  • The required AdSense entry uses four standard comma-separated fields containing your unique publisher ID, the DIRECT relationship label, and Google's certification authority ID.
  • Verification requires confirming public HTTP 200 access at your root URL and allowing Google crawlers several days to update the status in your AdSense console.

To create and verify an ads.txt file for AdSense, you need to create a plain-text file named ads.txt, add your unique publisher declaration line, upload it to the root directory of your domain, and verify that the file returns an HTTP 200 status code in a web browser. Once uploaded, Google crawlers automatically check the file to confirm that your account is authorized to sell ad space on that domain.

When your website shows AdSense ads without an ads.txt file, or with errors inside the file, ad networks cannot confirm who owns the advertising inventory. Advertisers frequently bid lower prices or refuse to buy impressions on unverified sites to protect themselves from domain spoofing. Adding this single text file secures your ad space, protects your earnings, and removes warning alerts from your AdSense dashboard. Let us do this step by step so you can set it up cleanly and maintain it without issues.

Prerequisites: What You Need Before Starting

Before creating the file, gather these three basic items:

  • Your Google AdSense Publisher ID: This is a unique identification string starting with pub- followed by 16 digits (for example, pub-0000000000000000).
  • Root-level server or CMS access: You need permission to upload files to your web server (via cPanel File Manager, SFTP, or an official CMS settings panel).
  • A basic plain-text editor: Use Notepad on Windows, TextEdit on macOS (set to plain text mode), or a code editor such as VS Code. Do not use word processors like Microsoft Word or Google Docs because they add hidden formatting codes.

Step 1: Find Your Authorized Publisher Entry

The first step is finding your exact publisher ID from your AdSense account. Follow these steps:

  1. Sign in to your Google AdSense account.
  2. Click on Sites in the left navigation menu.
  3. If a site shows a status of "Requires review" or displays an alert saying "Earnings at risk: You need to fix some ads.txt file issues", click on the notification or select your site name.
  4. AdSense provides a pre-formatted snippet that looks like this:
google.com, pub-XXXXXXXXXXXXXXXX, DIRECT, f08c47fec0942fa0

If you prefer to locate your publisher ID manually, navigate to Account > Settings > Account information in your AdSense console. Copy the 16-digit number that follows the pub- prefix.

Step 2: Format the Plain-Text File Correctly

The ads.txt specification was created by the IAB Tech Lab. The name stands for Authorized Digital Sellers. It uses a strict comma-delimited format. A single line for Google AdSense consists of four distinct parameters:

  1. Field 1 (Domain name of the advertising system): For AdSense, this is always google.com.
  2. Field 2 (Publisher Account ID): Your unique AdSense identifier, including the pub- prefix.
  3. Field 3 (Supply relationship): For accounts that directly own the relationship with the ad platform, this value is DIRECT. If you work through a third-party ad reseller or agency managing the inventory on your behalf, this value would be RESELLER. For standard AdSense accounts, use DIRECT.
  4. Field 4 (Certification authority ID): Google's unique security tag in the IAB register. For Google AdSense, this tag is always f08c47fec0942fa0.

Illustrative Example

Imagine your AdSense publisher ID is pub-1234567890123456. In your plain-text editor, create a brand-new file and paste this single line:

google.com, pub-1234567890123456, DIRECT, f08c47fec0942fa0

Save the file with the exact name ads.txt using standard UTF-8 encoding. Make sure your operating system does not append an extra extension such as ads.txt.txt.

Step 3: Choose the Correct Site Root Directory

The ads.txt protocol requires crawlers to query only the top-level root of your domain. It must sit directly under your domain name, never in a sub-folder.

For example, if your website address is https://example.com, your file must resolve at:

https://example.com/ads.txt

Placing the file in a directory like https://example.com/blog/ads.txt or https://example.com/assets/ads.txt will cause crawlers to miss it completely.

Root vs. Subdomain Rules

Ad crawlers check the root domain first. If your primary content runs on a subdomain such as app.example.com or shop.example.com, the crawler still searches for example.com/ads.txt. Unless you explicitly set up a subdomain referral entry, always host your ads.txt on the root domain.

Uploading Based on Your Platform

Depending on your hosting environment, the procedure differs:

  • Custom Web Hosting (cPanel / Nginx / Apache): Open your File Manager or connect via SFTP. Navigate to your website's public root folder (often named public_html, www, or htdocs). Upload the ads.txt file directly into that root folder.
  • WordPress: You can upload the file directly to your WordPress installation directory (where wp-config.php is located) via your hosting panel. Alternatively, you can use a dedicated ads.txt management plugin from the official WordPress plugin repository to paste the text string into your site settings.
  • Blogger: If your site runs on Google's blogging platform, you do not need to upload a raw file to a server. You can follow the dedicated steps in How to Connect AdSense to Blogger Step by Step to paste your entry into the Custom ads.txt field under Blogger Settings > Monetization.
monitor screengrab
Photo by Stephen Phillips - Hostreviews.co.uk on Unsplash

Step 4: Check Redirects and Public Access

Once you place the file, test its public accessibility before waiting on Google's crawlers. Open an incognito browser window and type your full ads.txt URL into the address bar:

https://example.com/ads.txt

You should see a plain white screen displaying only your text string. If you see a 404 Not Found error, a login page, or your site's custom home page layout, the file is in the wrong location or server permissions are blocking access.

Understanding Redirect Rules

Standard HTTP redirects are permitted by the IAB ads.txt crawler specification, but they must follow strict logic:

  • HTTP to HTTPS: Redirecting from http://example.com/ads.txt to https://example.com/ads.txt via a 301 or 302 redirect is completely valid.
  • Non-WWW to WWW (or vice-versa): Redirecting between your canonical domain versions is permitted.
  • Maximum Hop Limit: Avoid chained redirects. The crawler will stop following redirects after multiple hops. Ensure your server routes the request cleanly to the final destination.
  • Final Response Code: The final destination must return an HTTP status code of 200 OK with a MIME content type of text/plain.

Step 5: Verify Account Status After Crawling

After confirming that your file is accessible in your web browser, Google must crawl and index the file. This process is fully automated. Google checks ads.txt files periodically, but updates are not instantaneous.

According to official policy standards, publishers must adhere to AdSense program policies, maintain accurate records, and ensure their sites remain compliant AdSense Program Policies. The crawling engine typically checks your ads.txt file within 24 to 48 hours. In some hosting scenarios, it can take up to a few days for the warning banner inside AdSense to disappear.

Checking Status in the AdSense Console

  1. Sign in to your AdSense dashboard.
  2. Click on Sites.
  3. Look at the column labelled ads.txt next to your domain.
  4. When verification completes, the status changes to Authorized.
  5. If the status displays Not found or Unauthorized, click on the site row to see the exact timestamp when Google last attempted to crawl your domain.

Record Maintenance Responsibilities

An ads.txt file is not a set-and-forget file that you can ignore forever. As your monetization strategy evolves, the file requires regular maintenance.

Assign clear internal responsibilities for your website:

  • Keep an Offline Backup: Always keep a copy of your verified ads.txt file in your local documentation or Git repository. CMS core updates, migrations, or caching plugin updates can occasionally overwrite or delete root files.
  • Audit Additional Networks: If you add third-party advertising partners, header bidding partners, or mediation platforms, each partner will provide their own ads.txt lines. Append new lines below your AdSense line; never delete existing authorized entries unless you have stopped working with that vendor.
  • Schedule Quarterly Reviews: Check your live URL every three months. Ensure old partners whom you no longer use are removed so unauthorized parties cannot claim your inventory.
graphs of performance analytics on a laptop screen
Photo by Luke Chesser on Unsplash

Common Mistakes That Break Ads.txt Crawling

Even a tiny formatting mistake can invalidate your entire ads.txt file. Review this checklist to prevent common errors:

Mistake Why It Breaks How to Correct It
Typo in Publisher ID Using the letter 'O' instead of zero '0' or missing a digit prevents matching with your account. Copy your publisher ID directly from your AdSense Account settings tab.
Hidden Double Extension Windows or macOS text editors may save the file as ads.txt.txt. Enable file extensions in your file manager to confirm the name is strictly ads.txt.
Blocked by robots.txt A rule such as Disallow: /ads.txt stops Google crawlers from accessing the file. Ensure your robots.txt allows crawler user-agents to read the file path.
Rich Text Formatting Pasting into Word or rich editors introduces curly quotes or non-standard spaces. Use a plain-text editor with plain ASCII or UTF-8 formatting and standard comma separation.
Security Firewall Blocks Cloudflare or security plugins sometimes challenge crawlers with CAPTCHA pages. Whitelist the ads.txt URL so search engine and ad crawlers bypass verification screens.

How to Verify Your Result

Do not wait for the AdSense dashboard to update before testing your setup. Follow this concrete three-step verification process immediately after uploading:

1. The Browser Clean-Load Test

Navigate to https://example.com/ads.txt. Check that:

  • The URL loads without any security certificate warning.
  • The page body shows only plain text lines without HTML tags (such as <html> or <body>).
  • There are no trailing spaces or blank lines before your publisher entry.

2. The HTTP Header and Status Code Test

Using an online HTTP status checker or your command terminal, check the response headers for your ads.txt URL. If using a terminal, enter:

curl -I https://example.com/ads.txt

Verify that the response returns HTTP/1.1 200 OK or HTTP/2 200. Look at the Content-Type line; it should read text/plain.

3. Check Crawl Accessibility

Check your site's robots.txt file located at https://example.com/robots.txt. Confirm that there are no directives blocking Google's ad crawler (Mediapartners-Google) or blocking all crawlers from accessing files with the .txt extension.

Limitations and Important Technical Boundaries

Setting up ads.txt is an essential authorization step, but understand its operational boundaries:

  • It Does Not Guarantee Approval: Having an authorized ads.txt file does not mean your site automatically passes AdSense content quality or policy reviews. Content policies must still be met independently.
  • No Immediate Ad Serving: If your account has ad serving limits or policy restrictions, adding ads.txt will not lift those restrictions on its own.
  • Hosting Limitations: On free shared platforms or restricted website builders where you do not have root directory access or custom domain mapping, you cannot host an ads.txt file. In such cases, contact the platform provider or upgrade to custom domain hosting.

Next Actions

Now that your ads.txt file is published and returning a clean 200 status code, allow 24 to 48 hours for Google's systems to crawl your domain and mark the status as "Authorized" under your Sites menu.

Once verification is complete, focus on providing a clear reading environment. Review How to Place AdSense Ads Without Hurting User Experience to ensure your ad units are positioned effectively across desktop and mobile screens without violating placement guidelines.

Frequently Asked Questions

Is an ads.txt file mandatory to display Google AdSense ads?

Using an ads.txt file is not strictly mandatory to display ads, but Google highly recommends it. Without an ads.txt file, your inventory remains unverified, which can cause ad networks to withhold bids or pay significantly lower rates. Adding the file protects your revenue and prevents unauthorized inventory spoofing.

How long does it take for AdSense to verify my ads.txt file?

Google's automated crawlers typically check updated ads.txt files within 24 to 48 hours after upload. However, account dashboard status updates can occasionally take up to several days to reflect the change depending on crawl queues and site caching. As long as your URL returns an HTTP 200 status code publicly, verification will process automatically.

Can I add entries for other advertising networks into the same ads.txt file?

Yes. The ads.txt specification allows multiple ad networks in a single document. Each advertising network provides its own formatted lines with its exchange domain, account ID, and relationship type. You can append new lines directly below your existing AdSense line in the same plain-text file without separating them into different files.

Post a Comment