How to connect your site to AdSense: the three verification methods compared
Key takeaways
- AdSense offers three ways to connect a site: the AdSense code snippet in the page head, an ads.txt snippet in the root ads.txt file, or a google-adsense-account meta tag.
- The AdSense code snippet and the meta tag both go between the <head> and </head> tags; the ads.txt line goes in a file at the site's root directory.
- Google suggests the meta tag if you don't want to place the AdSense code snippet on your homepage.
- Verification is done by the AdSense crawlers Mediapartners-Google and Google-Display-Ads-Bot, so changes must be published and accessible to them.
- After clicking Verify, you click Request review; Google says the review usually takes a few days but can take 2-4 weeks.

To connect a site to AdSense, add it under “Sites”, then prove ownership with one of three methods: the AdSense code snippet in your page <head>, a line in your root ads.txt file, or a google-adsense-account meta tag. Click “Verify”, then “Request review”. Any method works; choose the one you can publish reliably on the exact domain you submitted.
The three connection methods compared
| AdSense code snippet | ads.txt snippet | Meta tag | |
|---|---|---|---|
| Where it goes | Between <head> and </head> |
ads.txt in the site’s root directory |
Between <head> and </head> |
| Loads ad script | Yes | No | No |
| Also serves ads later | Yes (needed for Auto ads and units anyway) | No | No |
| Needs root access | No, template access is enough | Yes, the domain root | No |
| Google’s suggested use | Default method | When you manage ads.txt | “If you don’t want to place the AdSense code snippet on your homepage” |
| Typical failure | Code on wrong site, stripped by CMS or consent tool | File not at root, redirect, wrong publisher ID | Tag in body, CMS removes unknown meta |
A fourth route exists for when the others are not possible: Google’s “not ready” help page says you can verify site ownership in Search Console instead of pasting code or creating an ads.txt file.
How do I connect my site? Step by step
If the site is not in your account yet
- Sign in to AdSense and click “Sites”.
- Click “+New site” and enter the URL.
- Click “Save”. The site appears with the status “Requires review”.
On a brand-new account, the homepage shows a “Connect your site to AdSense” card instead; click “Let’s go”. Blogger and YouTube sites are added from Blogger or YouTube Studio, not here.
Choose and apply a method
Method 1: AdSense code snippet
Copy the code shown in your account exactly. Google’s example looks like this, with your own publisher ID:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456"
crossorigin="anonymous"></script>
Paste it between <head> and </head>. Google asks that you place it “on every page you want ads to appear”, so the shared layout or header template is the right place.
Method 2: ads.txt snippet
Add this line (with your own publisher ID) to ads.txt and upload the file to the root directory, so it is served at https://example.com/ads.txt:
google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0
If you already have an ads.txt file, add the line to it; Google says to paste the code “into each ads.txt file” if there are several. Line-by-line explanations are in ads.txt syntax for AdSense.
Method 3: Meta tag
<meta name="google-adsense-account" content="ca-pub-0000000000000000">
Paste it between <head> and </head>. Note the format difference: the meta tag and the code snippet use ca-pub-..., while ads.txt uses pub-... without the ca- prefix.
Verify and request review
- Back in AdSense, select the check box confirming you have finished.
- Click “Verify”. AdSense checks the site with its crawlers.
- Click “Request review”.
- Optionally, choose a consent management platform: Google’s CMP (Google then creates a European regulations message for the site, with a two-button or three-button layout) or a certified third-party CMP.
Google says the review “usually takes a few days, but in some cases it can take 2-4 weeks”. Make sure your payments information is entered to avoid delays. The status meanings are in AdSense site statuses explained.
Which method fits your setup?
| Your situation | Practical choice | Why |
|---|---|---|
| WordPress or a CMS with header access | AdSense code snippet | You will need it for ads anyway |
| Static site or framework (Astro, Hugo, Next.js) | Code snippet in the base layout, or the meta tag | One edit in the layout covers every page |
| You cannot add scripts yet (consent setup pending, strict CSP) | Meta tag | No script is loaded |
| You can only upload files, not edit templates | ads.txt snippet | A single root file |
| None of the above works | Search Console verification | Listed by Google as an alternative |
How do I check the snippet is really live?
Before clicking “Verify”, confirm what an anonymous visitor (and the crawler) receives, not what your editor shows:
curl -s https://example.com/ | grep -o 'ca-pub-[0-9]*'
curl -s https://example.com/ads.txt
The first command should print your publisher ID once (or twice if you use both the script and the meta tag). The second should print the google.com, pub-... line. If either comes back empty, the problem is on the site side, and AdSense will not see the change either.
Sites linked to a platform partner
Some hosting or publishing platforms are AdSense platform partners. For those, Google’s flow is different: either paste your publisher ID into the platform’s setup page or confirm setup is complete on the platform, then click “Next”, “Verify” and “Request review”. Google treats ad requests as “shared traffic” if your ad code contains the data-ad-host parameter or the page carries the google-adsense-platform-account meta tag; the platform may then control ad settings, ads.txt and part of the revenue share.
Why does verification fail?
Google’s connection troubleshooting has two headings. Work through the one you see.
“The code is missing or incomplete”
- Is the code in the HTML of the site, between
<head>and</head>? - Is it on the site you used to sign up, not a staging or other domain?
- Is it on a page that has content and receives regular visitors?
Practical causes behind those questions:
| Cause | How to detect | Fix |
|---|---|---|
| Caching or CDN still serves the old HTML | View source in a private window, look for ca-pub- |
Purge the cache, redeploy |
| CMS or editor strips scripts | The code vanishes after saving | Use the theme header, a header hook or a template file |
| Script only injected after consent | Code absent from raw HTML | Load the verification snippet (or the meta tag) unconditionally; handle consent through a certified CMP |
| Code added by JavaScript in a single-page app | Not in the initial HTML | Put it in the static HTML head |
| Publisher ID typo | Compare with the ID in your account | Recopy from AdSense |
“Your site is unreachable”
- Is the URL in AdSense correct? If not, remove the site and add it again with the right URL.
- Is the site published and live?
- Is the site behind a login? Remove the login during review; after activation, you can set up a crawler login.
- Does robots.txt block the AdSense crawler? Google’s add-a-site page names both crawlers that must access your changes:
Mediapartners-GoogleandGoogle-Display-Ads-Bot.
If the method you chose keeps failing, Google suggests you “can try a different verification method”. A full diagnostic for access problems is in the approval checklist.
Common mistakes when connecting a site
- Verifying
wwwwhile the site lives on the bare domain (or the reverse) with no redirect between them. - Putting ads.txt in a subfolder such as
/blog/ads.txtor behind a redirect to another host. It must be at the root of the domain you added. - Pasting the meta tag or snippet into the body through a widget. Both belong in the head.
- Using an old ad code from another account. The publisher ID must be the one of the account where you added the site.
- Removing the code right after verification. Keep it in place during the review; for ads you will need it on every page anyway.
On frameworks where the head is generated by components, the placement differs slightly; see AdSense in Astro for one worked example.
Frequently asked questions
Which AdSense verification method should I choose?
Use the AdSense code snippet if you plan to use Auto ads or ad units anyway, since the same code serves ads later. Use the meta tag if you want verification without loading ad code yet. Use the ads.txt snippet if you control the root of the domain and want to publish ads.txt from day one. All three are official; pick the one you can deploy cleanly.
Do I need ads.txt if I verified with the code snippet?
Not for verification, but Google recommends publishing an ads.txt file to protect your site from being sold to advertisers from accounts you don't own, and the Sites page flags "Not found" or "Unauthorized" ads.txt statuses. Adding the file early avoids ads.txt warnings once ads start serving.
Does the AdSense code have to be on every page for approval?
For verification, Google asks that it is on the site you registered, on a page with content that receives regular visitors. For showing ads, Google says to place the code on every page where you want ads to appear. Putting it in the shared head template covers both needs at once.
Can I verify my site through Search Console instead?
Yes. Google's help page on sites that are not ready lists verifying site ownership in Search Console as an alternative to pasting the code in the head or creating an ads.txt file. AdSense then continues checking whether the site is ready.
Sources
- Connect your site to AdSense · Google AdSense Help
- Add a new site to your AdSense sites list · Google AdSense Help
- What to do when your site is not ready to show ads · Google AdSense Help
- Your site is linked to a platform partner · Google AdSense Help
Related guides
- AdSense site statuses explained: what each status on the Sites page means and what to do
What "Requires review", "Getting ready", "Needs attention" and "Ready" mean on the AdSense Sites page, plus the ads.txt column, and the exact next step for each.
- ads.txt syntax for AdSense, line by line: pub ID, DIRECT, TAG ID, comments and variables
The AdSense ads.txt line field by field: google.com, your pub ID, DIRECT, f08c47fec0942fa0, plus comments, variables and the formatting errors that break parsing.
- Auto ads vs manual ad units: which one to use, and how to combine them
Auto ads or manual ad units? Compare control, formats, page and area exclusions, and how AdSense combines both on one page without double work.
- How to add Google AdSense to an Astro site (with or without view transitions)
Add AdSense to an Astro site: unprocessed head script, a reusable ad unit component, ClientRouter view transitions, production-only loading and ads.txt.
- AdSense approval checklist: everything to verify before you request a site review
A pre-submission AdSense checklist mapped to Google's eligibility rules, setup tasks and site review reasons, so you fix issues before you request review.