Use Adsense on password protected sites

adsenseauth_20070721.jpg

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.


Recent Entries

Comments

Oldest comments listed first.

Posted by: a2a2ron on July 22, 2007 at 11:37 AM

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.


Leave a comment


Subscribe to MAKE!Subscribe to MAKE Magazine!

Subscribe today, save 42% and get web access to MAKE free. MAKE Digital Edition is available only to subscribers.

$34.95 / 1 year
(4 Quarterly Issues)

Subscribe now


Void your warranty, violate a user agreement, fry a circuit, blow a fuse, poke an eye out. Make: The risk-takers, the doers, the makers of things... Welcome to Make: Online!


CRAFT Maker Shed Maker Faire MAKE television




Check out more videos from MAKE.

MZ_Jameco-RobotBuild_RR.gif
MZ_DIYMovieMaking-RR.gif
Maker SHED

Connect with MAKE

Be a MAKE fan on Facebook MAKE on Facebook
Visit our Facebook page and become a fan of MAKE!
MAKE on Twitter MAKE on Twitter
Follow our MAKE tweets!
MAKE Flickr Pool MAKE on Flickr
Join our MAKE Flickr Pool!
    make_tips on Twitter



    MAKE Archives

    Make: Money

    Make: Science Room
    Subscribe to MAKE Magazine!

    Make: Online editors and authors!

    Gareth BranwynGareth Branwyn
    Editor-in-Chief


    Phillip TorronePhillip Torrone
    Senior Editor
    | Web | Twitter


    Becky SternBecky Stern
    Associate Editor
    | AIM | Twitter


    Marc de VinckMarc de Vinck
    Contributing Writer
    | AIM | Twitter


    John ParkJohn Park
    Contributing Writer
    | Twitter


    Sean RaganSean Ragan
    Contributing Writer
    | Twitter


    Matt MetsMatt Mets
    Contributing Writer
    | AIM | Twitter


    Dale DoughertyDale Dougherty
    Editor & Publisher
    | Twitter


    Shawn ConnallyShawn Connally
    Managing Editor
    | Twitter


    Goli MohammadiGoli Mohammadi
    Associate Managing Editor

    Kip KayKip Kay
    Weekend Projects
    | AIM | Twitter


    Collin CunninghamCollin Cunningham
    Contributing Writer
    | AIM | Twitter

    Adam FlahertyAdam Flaherty
    Contributing Writer
    | AIM | Twitter


    John BaichtalJohn Baichtal
    Contributing Writer
    | AIM | Twitter



    More contributors: Mark Frauenfelder (Editor-in-Chief, MAKE magazine), Kipp Bradford (Technical Consultant/Writer), Chris Connors (Education), Diana Eng (Guest Author), Peter Horvath (Intern), Brian Jepson (O'Reilly Media), Robert Bruce Thompson (Science Room)

    Suggest a Site!

    Advertise here with FM.

    Why advertise on MAKE?
    Read what folks are saying about us!

    Click here to advertise on MAKE!



    Current Podcast

    itunesdl.gif John Park in the Maker Shed: tinyCylon kit build They let me loose in the Maker Shed, so I grabbed a tinyCylon Kit, built it, and embedded it in a busted Nerf gun! More...

    Get the Make: Online sent via email
    Enter your email to receive Make: Online each day:



    Sign up for the Make: Newsletter

    Our Make: Newsletter covers news from maker Media, has original columns, Shed deals, and more! You can also read the archives of past issues.


     



    MAKE Fascination video series brought to you by Dow

    Make: Education
    MAKE: en EspaƱol MAKE: Japan
    Important please read


    Subscribe to MAKE Magazine!

    Recent Posts from the Craft: Blog