Forum Moderators: martinibuster
You can of course get hold of this adsense javascript code by looking at the source code of any page with adsense adverts.
One aspect that I am interested in is how google finds what your content is (so that it knows what are the most appropriate adverts to show on the page) - does it do it "on the fly", so that when someone looks at your page, as the page is loading, the page content is sent back to google, they analyse this content for keywords and then send back the appropriate adverts to display?
OR is it the case that when someone clicks on an adsense advert - the page content is sent back to google. They then analyse this content (for keywords) - refining their knowlegde of your content so that they can provide more appropriate adverts the next time. So, in this way, with each click, they update their knowledge of your content.
OR - do they simply find the content of your site by crawling it with a robot. Perhaps there is an adsense specific google robot?
its pointless posting the same question on two different threads, I answered what you have posted again on the thread below
[webmasterworld.com...]
Ads are even better targetted once the page has been spidered by the search engine bot.
When targeting, AdSense MAY also take things into account such as:
- the domain/directory path/filename being viewed
- the referring page (e.g. the search string the surfer used if he or she got to the page via a search engine)
- information about other AdSense pages viewed or ads clicked by the surfer
- the domain/... being viewed"
It certainly does!
One of the domain names I was using was, I discovered once I started using adsense, a computing related term. Even though the content of the site made no mention whatsoever of computers, computing or anything remotely computer related, adsense dished up nothing but ads for computer stuff. So I guess domain names matter :)
I am interested in this "on the fly" assessment of content - assessment of content as the page loads. How sure are you guys that this happens? Can you identify the javascript code that does this, in the adsense javascript code?
You add AdSense to a new page, someone displays the page, Google discover the page is not already in their database, and then they dispatch a spider within a few minutes or hours to download the page so that can add it to the database. Thus the first time a page is displayed, Google will not be able to target ads based on the actual text on the page.
Sometimes, when we put a new page up, targetted ads seem to appear instantaneously, on the first display of the page. Is this just an extremely fast spider? It used to be slower - up to a day or two - though that's still quicker than the UK's normal quarantine period for spiders :-).
Sometimes they'll give a domain a standard set of ads even if they don't know the page's content. They also base it on the url sometimes.
I've designed a page in dreamweaver and tested it with the Adsense code on it by mistake. Was surprised to see contextual ads when the url was a tmp file on my desktop.
I am interested in this "on the fly" assessment of content
1 mediabot will visit that page that your site visitor just viewed
2 the time scale of mediabot visiting can vary from less than a second to a few minutes or even hours (I have seen mediabot visit the same second the page was requested by a visitor)
3 on target ads appear on your page, (this is depending on the page content and also on the amount of advertisers in that niche)
mediabot will also visit again from time to time to check the content of a page but will "only" visit when the page is requested by a visitor, it does not crawl your pages for no reason
its that simple, there is no other way of describing this process and its certainly not what you are talking about
now moving onto your other question, there is no doubt that information is sent back to google, what do you think gives us the page views, clicks, ctr etc in our adsense login..?
RE: "now moving onto your other question, there is no doubt that information is sent back to google, what do you think gives us the page views, clicks, ctr etc in our adsense login..? "
Has anyone researched the google javascript code to see what parameters exactly are sent back to google upon a click?
1) Minimal Javascript code for Adsense
<script type="text/javascript">
<!--
google_ad_client = "(publisher-id)";
google_ad_width = (width);
google_ad_height = (height);
google_ad_format = "(format)";
//-->
</script>
<script type="text/javascript" src="http:// pagead2.googlesyndication.com/pagead/ show_ads.js"> </script>
2)
This is the code in the external file called in the code above. This external file is called "http:// pagead2.googlesyndication.com/pagead/ show_ads.js"
(function(){
// NOTE: This file is intended to be compiled with JSCompiler. If you are
// getting a compiler error when using a JavaScript built-in, please update
// google3/contentads/frontend/externs.js
function quoted(str) {
return (str!= null)? '"' + str + '"' : '""';
}
function google_encodeURIComponent(str) {
if (typeof(encodeURIComponent) == 'function') {
return encodeURIComponent(str);
} else {
return escape(str);
}
}
function google_write_tracker(d, ad_url, tracker_event) {
var qloc = ad_url.indexOf('?');
var img_src = 'http://pagead2.googlesyndication.com/pagead/imp.gif?event=';
img_src += tracker_event;
if (qloc!= -1 && qloc + 1 < ad_url.length) {
img_src += '&' + ad_url.substring(qloc + 1);
}
var img_tag = '<img height="1" width="1" border="0" ' +
'src=' + quoted(img_src) +
' />';
d.write(img_tag);
}
function google_append_url(param, value) {
if (value) {
window.google_ad_url += '&' + param + '=' + value;
}
}
function google_append_url_esc(param, value) {
if (value) {
google_append_url(param, google_encodeURIComponent(value));
}
}
function google_append_color(param, value, random) {
if (value && typeof(value) == 'object') {
value = value[random % value.length];
}
google_append_url('color_' + param, value);
}
function google_get_user_data(w, date) {
var screen = w.screen;
var javaEnabled = navigator.javaEnabled();
var tz = -date.getTimezoneOffset();
if (screen) {
google_append_url("u_h", screen.height);
google_append_url("u_w", screen.width);
google_append_url("u_ah", screen.availHeight);
google_append_url("u_aw", screen.availWidth);
google_append_url("u_cd", screen.colorDepth);
}
google_append_url("u_tz", tz);
google_append_url("u_his", history.length);
google_append_url("u_java", javaEnabled);
if (navigator.plugins) {
google_append_url("u_nplug", navigator.plugins.length);
}
if (navigator.mimeTypes) {
google_append_url("u_nmime", navigator.mimeTypes.length);
}
}
function google_modify_client(client) {
client = client.toLowerCase();
if (client.substring(0, 3)!= 'ca-') {
client = 'ca-' + client;
}
return client;
}
function google_write_iframe(w, d, ad_url) {
ad_url = ad_url.substring(0, 1000);
ad_url = ad_url.replace(/%\w?$/, '');
if (w.google_ad_output == 'js' &&
(w.google_ad_request_done ¦¦ w.google_radlink_request_done)) {
d.write('<script language="JavaScript1.1"' +
' src=' + quoted(ad_url) + '></' + 'script>');
} else if (w.google_ad_output == 'html') {
if (w.name == 'google_ads_frame') {
google_write_tracker(d, ad_url, 'reboundredirect');
} else {
d.write('<iframe' +
' name="google_ads_frame"' +
' width=' + quoted(w.google_ad_width) +
' height=' + quoted(w.google_ad_height) +
' frameborder=' + quoted(w.google_ad_frameborder) +
' src=' + quoted(ad_url) +
' marginwidth="0"' +
' marginheight="0"' +
' vspace="0"' +
' hspace="0"' +
' allowtransparency="true"' +
' scrolling="no">');
google_write_tracker(d, ad_url, 'noiframe');
d.write('</iframe>');
}
}
}
function google_reset_variables(w) {
var nullvalue = null;
w.google_ad_frameborder = nullvalue;
w.google_ad_format = nullvalue;
w.google_page_url = nullvalue;
w.google_language = nullvalue;
w.google_gl = nullvalue;
w.google_country = nullvalue;
w.google_region = nullvalue;
w.google_city = nullvalue;
w.google_hints = nullvalue;
w.google_safe = nullvalue;
w.google_encoding = nullvalue;
w.google_ad_output = nullvalue;
w.google_max_num_ads = nullvalue;
w.google_ad_channel = nullvalue;
w.google_contents = nullvalue;
w.google_alternate_ad_url = nullvalue;
w.google_alternate_color = nullvalue;
w.google_color_bg = nullvalue;
w.google_color_text = nullvalue;
w.google_color_link = nullvalue;
w.google_color_url = nullvalue;
w.google_color_border = nullvalue;
w.google_color_line = nullvalue;
w.google_adtest = nullvalue;
w.google_kw_type = nullvalue;
w.google_kw = nullvalue;
w.google_num_radlinks = nullvalue;
w.google_max_radlink_len = nullvalue;
w.google_rl_filtering = nullvalue;
w.google_rl_mode = nullvalue;
w.google_rt = nullvalue;
w.google_ad_type = nullvalue;
w.google_image_size = nullvalue;
w.google_feedback = nullvalue;
w.google_skip = nullvalue;
w.google_page_location = nullvalue;
w.google_referrer_url = nullvalue;
w.google_ad_region = nullvalue;
w.google_ad_section = nullvalue;
w.google_bid = nullvalue;
w.google_cpa_choice = nullvalue;
}
function google_show_ad() {
var nullvalue = null;
var w = window;
var d = document;
var date = new Date();
var random = date.getTime();
var format = w.google_ad_format;
if (w.google_cpa_choice) {
w.google_ad_url = 'http://pagead2.googlesyndication.com/cpa/ads?';
w.google_ad_url += 'client=' +
escape(google_modify_client(w.google_ad_client));
google_append_url('cpa_choice', w.google_cpa_choice);
google_append_url_esc('format', format.toLowerCase());
google_get_user_data(w, date);
google_write_iframe(w, d, w.google_ad_url);
google_reset_variables(w);
return;
}
var num_slots_by_client = w.google_num_slots_by_client;
var num_slots_by_channel = w.google_num_slots_by_channel;
var prev_ad_formats = w.google_prev_ad_formats_by_region;
w.onerror = w.google_org_error_handler;
if (w.google_ad_region == nullvalue && w.google_ad_section!= nullvalue) {
w.google_ad_region = w.google_ad_section;
}
var region = (w.google_ad_region == nullvalue)? '' : w.google_ad_region;
var is_zero_ad_format = false;
if (format) {
is_zero_ad_format = ((format).indexOf('_0ads')) > 0;
}
if (is_zero_ad_format) {
if (w.google_num_0ad_slots) {
w.google_num_0ad_slots = w.google_num_0ad_slots + 1;
} else {
w.google_num_0ad_slots = 1;
}
if (w.google_num_0ad_slots > 1) {
return;
}
} else {
if (w.google_num_ad_slots) {
w.google_num_ad_slots = w.google_num_ad_slots + 1;
} else {
w.google_num_ad_slots = 1;
}
if (w.google_num_slots_to_rotate) {
prev_ad_formats[region] = nullvalue;
if (w.google_num_slot_to_show == nullvalue) {
w.google_num_slot_to_show = random % w.google_num_slots_to_rotate + 1;
}
if (w.google_num_slot_to_show!= w.google_num_ad_slots) {
return;
}
} else if (w.google_num_ad_slots > 3 && region == '') {
return;
}
}
w.google_ad_url = 'http://pagead2.googlesyndication.com/pagead/ads?';
w.google_ad_url += 'client=' +
escape(google_modify_client(w.google_ad_client));
google_append_url('dt', date.getTime());
google_append_url('hl', w.google_language);
if (w.google_country) {
google_append_url('gl', w.google_country);
} else {
google_append_url('gl', w.google_gl);
}
google_append_url('gr', w.google_region);
google_append_url_esc('gcs', w.google_city);
google_append_url_esc('hints', w.google_hints);
google_append_url('adsafe', w.google_safe);
google_append_url('oe', w.google_encoding);
google_append_url('lmt', w.google_last_modified_time);
google_append_url_esc('alternate_ad_url',
w.google_alternate_ad_url);
google_append_url('alt_color', w.google_alternate_color);
google_append_url("skip", w.google_skip);
var client = w.google_ad_client;
if (!num_slots_by_client[client]) {
num_slots_by_client[client] = 1;
num_slots_by_client.length += 1;
} else {
num_slots_by_client[client] += 1;
}
if (prev_ad_formats[region]) {
google_append_url_esc('prev_fmts',
prev_ad_formats[region].toLowerCase());
if (num_slots_by_client.length > 1) {
google_append_url('slot', num_slots_by_client[client]);
}
}
if (format) {
google_append_url_esc('format', format.toLowerCase());
if (prev_ad_formats[region]) {
prev_ad_formats[region] = prev_ad_formats[region] + ',' + format;
} else {
prev_ad_formats[region] = format;
}
}
google_append_url('num_ads', w.google_max_num_ads);
google_append_url('output', w.google_ad_output);
google_append_url('adtest', w.google_adtest);
if (w.google_ad_channel) {
var chnl = w.google_ad_channel.toLowerCase();
google_append_url_esc('channel', chnl);
var pv_ch = '';
var arr = chnl.split('+');
for (var i = 0; i < arr.length; i++) {
var ch = arr[i];
if (!num_slots_by_channel[ch]) {
num_slots_by_channel[ch] = 1;
} else {
pv_ch += ch + '+';
}
}
google_append_url_esc('pv_ch', pv_ch);
}
google_append_url_esc('url', w.google_page_url);
google_append_color('bg', w.google_color_bg, random);
google_append_color('text', w.google_color_text, random);
google_append_color('link', w.google_color_link, random);
google_append_color('url', w.google_color_url, random);
google_append_color('border', w.google_color_border, random);
google_append_color('line', w.google_color_line, random);
google_append_url('kw_type', w.google_kw_type);
google_append_url_esc('kw', w.google_kw);
google_append_url_esc('contents', w.google_contents);
google_append_url('num_radlinks', w.google_num_radlinks);
google_append_url('max_radlink_len',
w.google_max_radlink_len);
google_append_url('rl_filtering', w.google_rl_filtering);
google_append_url('rl_mode', w.google_rl_mode);
google_append_url('rt', w.google_rt);
google_append_url('ad_type', w.google_ad_type);
google_append_url('image_size', w.google_image_size);
google_append_url('region', w.google_ad_region);
google_append_url('feedback_link', w.google_feedback);
google_append_url_esc('ref', w.google_referrer_url);
google_append_url_esc('loc', w.google_page_location);
google_append_url('bid', w.google_bid);
if (google_onpage(w, d) && d.body) {
var scr_h = d.body.scrollHeight;
var clt_h = d.body.clientHeight;
if (clt_h && scr_h) {
google_append_url_esc('cc', Math.round(clt_h * 100 / scr_h));
}
}
google_get_user_data(w, date);
google_write_iframe(w, d, w.google_ad_url);
google_reset_variables(w);
}
function google_error_handler(message, url, line) {
google_show_ad();
return true;
}
function google_onpage(w, d) {
return w.top.location == d.location;
}
function google_in_adframe(w, d) {
var documentElement = d.documentElement;
if (google_onpage(w, d)) return false;
if (w.google_ad_width && w.google_ad_height) {
var wd = 1;
var ht = 1;
if (w.innerHeight) {
wd = w.innerWidth;
ht = w.innerHeight;
} else if (documentElement && documentElement.clientHeight) {
wd = documentElement.clientWidth;
ht = documentElement.clientHeight;
} else if (d.body) {
wd = d.body.clientWidth;
ht = d.body.clientHeight;
}
if (ht > 2 * w.google_ad_height ¦¦ wd > 2 * w.google_ad_width) {
return false;
}
}
return true;
}
function google_init_globals() {
var w = window;
var d = document;
var location = d.location;
var referrer = d.referrer;
var nullvalue = null;
w.google_org_error_handler = w.onerror;
w.onerror = google_error_handler;
if (w.google_ad_frameborder == nullvalue) {
w.google_ad_frameborder = 0;
}
if (w.google_ad_output == nullvalue) {
w.google_ad_output = 'html';
}
if (w.google_ad_format == nullvalue && w.google_ad_output == 'html') {
w.google_ad_format = w.google_ad_width + 'x' + w.google_ad_height;
}
if (w.google_page_url == nullvalue) {
w.google_page_url = referrer;
if (!google_in_adframe(w, d)) {
w.google_page_url = location;
w.google_last_modified_time = Date.parse(d.lastModified) / 1000;
w.google_referrer_url = referrer;
}
} else {
w.google_page_location = referrer;
if (!google_in_adframe(w, d)) {
w.google_page_location = location;
}
}
if (w.google_num_slots_by_channel == nullvalue) {
w.google_num_slots_by_channel = new Array();
}
if (w.google_num_slots_by_client == nullvalue) {
w.google_num_slots_by_client = new Array();
}
if (w.google_prev_ad_formats_by_region == nullvalue) {
w.google_prev_ad_formats_by_region = new Array();
}
}
google_init_globals();
google_show_ad();
})()
Has anyone researched the google javascript code to see what parameters exactly are sent back to google upon a click?
quite a lot: screen resolution, system information, cookies, referers (pages that contained a link to your page), and even loads of trivial stuff such as version number and descriptions of all the installed plug-ins.
With all this information, for all practical use you are uniquely identified!
PLUS the javascript loads another javascript that being dyanmically generated could do anything elese :-)
What is the name of the second javascript file (name.js) called? I cant find a second .js file. The only one I can find is the "http:// pagead2.googlesyndication.com/pagead/ show_ads.js". Which is the one cut and paste above. Do you mean that there is a second .js file called within this .js file?
d.write('<script language="JavaScript1.1"' +
' src=' + quoted(ad_url) + '></' + 'script>');
the ad_url variable is a long variable that contains
the URL [pagead2.googlesyndication.com...] and then all the "interesting" information
Also, note the google_write_tracker() function, that calls an image passing as a parameter the same ad_url variable.
I just want to withdraw this. Today we put up a page with an obscure URL that was unconnected with any other content on any of our sites. On first display it had targeted ads (ie in the new area for this page). The page loaded first, then the targeted ads followed less than a second later.