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 http://examplesite.com/user/login?destination=node 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 http://www.restrictedsite.com/ or https://www.testsite.com/membersonly 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 http://examplesite.com/user/login?destination=node
- 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.
ADVERTISEMENT