Use Adsense on password protected sites

Use Adsense on password protected sites


In order to display relevant advertisements, Adsense has its own web crawler which scans Adsense enabled URLs for page content. This helps Adsense get a clue of what the particular page is all about, and enables it to display ads with purchased keywords that match your content.

For forums and other password protected sites, however, the Adsense crawler is usually able to see only an error or login request page. With little information to go on, ads cannot be placed correctly, so Adsense on password protected sites was a bit of an impossibility. Until Google added the “Site Authentication” feature, that is.

If you go into Adsense setup, there’s a new tab called “Site Authentication”. On that tab, you can configure Adsense with the login and password information that it needs to authenticate with your site before indexing your pages for content. You’ll need to know a little about how your login form is configured for your particular site, but it’s fairly simple to figure out from looking at the source. Here’s an example:

Locate Form URL and Variables
The login form on a Drupal website that I run looks like this. I’ve stripped out everything but the form anf input fields, and your site may differ, but you can use this as an example:

<form action="user/login?destination=node" method="post">
<input type="text" maxlength="64" class="form-text" name="edit[name]" id="edit-name" size="15" value="" />
<input type="password" class="form-password" maxlength="64" name="edit[pass]" id="edit-pass" size="15" value="" />
<input type="submit" class="form-submit" name="op" value="Log in"  />

So from this I know that the form method is “POST”, the URL for the login page is and the’re are two user input fields for the username and password: “edit[name]” and “edit[pass]”. There is also the submit button, with the name “op” and the value of “Log in”. The submit button value may or may not be important for the log in script, but we’ll use it just in case.

Give Adsense Authentication Information

Now you can jump over to the “Site Authentication” page and add the necessary information. First, make a speical username and password on your site for Adsense to use. Adsense will be using this account to log in and browse your site’s content, so make sure it has the neccessary permissions to see everything that you want ads to appear on. For the purposes of this example, let’s say the new user is “adsenseuser” and the password is “123abc”.

  • In the restricted directory or url field, put the portion of your site’s URL that restricted content is under. This might be or or something like that.
  • For the authentication url field, enter in the url that you discovered earlier which the normal log in form is posting to. In the above example, this was
  • Select the correct authentication method. This will be “POST” in most scenarios.
  • Enter the login form field names and values. Our example has three fields: “edit[name]”, “edit[pass]”, and “op”. The values in this case would be “adsenseuser”, “123abc”, and “Log in”, respectively.

When you’ve finished, save your settings and you’ll be directed to Google’s webmaster tools to “claim your site”. This is the same tool used by Sitemaps, and all you’ll need to do is upload a small file to your site. This proves to Google that you are the owner of the site.

After your site is verified, and Adsense has had some time to index your site, you should notice more targeted ads start appearing on your restricted pages.

2 thoughts on “Use Adsense on password protected sites

  1. a2a2ron says:

    Thanks for the great tip. Very well written and will definitely help those of us trying to add a little relevancy to our AdSense ads.

    Love the site also – are you guys going to Vegas this November for Postiecon? It’s the one where they are announcing the winners of the Blogger’s Choice Awards – thought you might be interested.

  2. Доктор says:

    and what about drupal 7?

Comments are closed.

Discuss this article with the rest of the community on our Discord server!


Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).