How to get targeted adsense ads on Facebook app page requiring authentication

I have a Facebook iframe application that I am monetizing via Google Adsense. On pages that do not require Facebook authentication, the ads are served fine and reflect the content on the page. Pages that require a Facebook session have the ads rendered fine, but they are very generic. They only reflect the user's geography and not the page content (for example, Groupon ads for the user's city, and ads for random things like photo uploading services).

I would like to get Adsense to render targeted ads based on the page content. There is plenty of good content on the pages in question. They are not "content-free" pages like pure logon pages.

I am using an approach similar to the one in the accepted answer for this other question: google adsense in facebook application . My Adsense javascript is in a separate file that gets loaded into an iframe in my canvas page, which is in turn loaded into Facebook as an iframe (like any other Facebook iframe app). The file with the Adsense code has a bunch of relevant content to provide Adsense with the context for targeting the ads. This content is not visible to the user as I set the iframe to have no scrollbars and a limited height.

Is the problem that the Adsense bot (user agent Mediapartners-Google) gets blocked by the Facebook logon and can't indexing the page?

Or is the problem that when the user accesses the page, Facebook tacks on a very long querystring, resulting in Adsense treating it as a different page for every user? Then again, this has no impact on the iframe URL.

The solution recommended in that other stack overflow question calls for loading the file with the Adsense code and keywords using a frameset rather than an iframe. Would this really make a difference?

I am aware of the potential conflict with Adsense terms which prohibits loading Adsense via an iframe. For a Facebook app there really is no other way to do it, and since the app iframe has legitimate content for ad targeting and is "owned" by the publisher (me) it seems consistent with the spirit if not the letter of the Adsense terms of use.

I have toyed with the idea of changing my pages that require a Facebook session to be open, and just disable all controls and present a Facebook login button to users who visit those pages and are not logged into Facebook already. I would use the Javascript client library to manage the login and enabling of controls so the page does not refresh, so hopefully Adsense will read the content and delivery relevant targeted ads. This is a significant change to those pages however, so if there is a simpler solution I'd like to avoid this work.


Well I did nothing but wait a week or so and the ads started to get context-tuned and relevant, using the approach of putting the ads in an iframe that has masked-off context content (setting the iframe height and width to just show the ads, no scroll bars or border) that matches my app's subject.

I'm not sure why it took a week for Google to tune into the context and produce targeted ads on this page, but I won't look the gift horse in the mouth I guess.

Need Your Help

Coding NFC-chip in C and other NFC-questions

c nfc

Bear with me on this, I'm new to the NFC technology and also fairly new to coding.

Change Color of Div Dynamically - Javascript

javascript dynamic html colors

I think this should be a simple question, but I'm having trouble figuring it out. I have two divs within a parent div and I want to change the color of just the right div (javascript). My code loops