How does a third-party ad provider decide what ad to deliver to a web-page when it's loaded in a browser? And in what format is this data delivered?
Let's say my web-page contains no ad-relevant or differentiating content, but I do know lots about my user: demographic profile, interests, browsing history etc. So the ad I want loaded must be user- (profile-) dependent, and not page specific.
Is it possible, in an ad request from a browser to a third-party provider, to include profile data in the request in order to get an appropriate ad? If so in what format would this request likely be made, and how would the response be formatted? E.g XML, JSON etc.
Is it possible, in an ad request from
a browser to a third-party provider,
to include profile data in the request
in order to get an appropriate ad?
In general you have to inform your users (by law) that you give away their information to 3rd parties, (it's called 'privacy' ;)). Though in general, it's not done at an individual request basis. Websites sell ad-space to ad agencies who sell this space to advertisers. As websites have a given set of aspects, the advertisers buy X pageviews with sites which have aspect A, B and C for example. Ad agency then controls this: the website calls (usually in an iframe) the ad agency's ad server to provide an ad for aspect A, B and C and the ad server simply serves up an ad.
As it's an IFrame, the ad-agency can track the user through cookies, its OWN cookies. This is more valuable as they can track a user across multiple websites they server the ads for (so they can see which sites user X visits and for how long/which paths this user follows over the pages and combine that with the info the website passed to the ad-agency's ad servers in the iframe request.
The more YOU are giving out to 3rd parties (and you've to provide that info to your users) the more users will either block everything on your site which comes from 3rd parties or simply go away. Respect the privacy of your users. It will give you more in return than some big-brother deal with an ad-agency.
In general, the primary way ad networks work is that you add HTML to your page that references some resource via a URL (often with your account number or similar identifier) on a server that the ad network controls. The resource might be an image, a video, a chunk of JavaScript, or anything else really (an iFrame is another common one).
In most cases, it will be a chunk of JavaScript or an iFrame and the script will get an ad off of their network and set it inside a link. This link is usually a link back to their server, which then redirects the user clicking it to whatever destination the ad is driving traffic to.
By hitting a resource on their server, they are counting the number of "impressions" or "views" that particular piece of advertising got from your site, and by routing the click through their server, they are counting the number of clicks. Since you send them your account ID when you request the resource, they can associate this all with your account and pay you based on "cost-per-click" (CCP) and/or number of impressions.
As some of the other answers have mentioned, much of the "profile" information that the ad networks use is based on cookies that they, themselves, set, rather than being based on information from the web property that is displaying the ad. The way these cookies work, and how they allow the ad networks to build up such a specific profile of users is by relying on the Referer header of a web request.
The ad agencies will give each user a unique id as their cookie, and then every time a page makes a request to their servers, the request will include the URL of the page that the request came from, as well as including the cookie for the ad network (since it's a request to their server). If you have enough refering URLs for an individual, you can build up a pretty good idea about who they are and what they are interested in, including amazingly accurate demographic information.
Using the referer history for the user identified by the cookie, the ad network is able to have a much more detailed accurate picture of your user and what they want, since their profile is behavior-based (ie. the actual sites visited) rather than self-reported, like most user profiles.
Other examples of non-standard ads (eg. a banner somewhere) include ad networks that use a script to scan the text content of your pages and selectively turn some words into links, often with larger ads that pop up when the user's mouse goes over them. A variation on this are the ads that pop up when you first enter a site, or ones that "attach" to the users' cursor for a specified amount of time.
All of these examples, however, are rather invasive and will likely piss your users off and will reduce the number of users you have on your site, which is a BAD THING. Google has done lots and lots of research regarding effective ad placement, including things like size, color, differentiation from the rest of the site content, etc. and they make much of this information available through the AdSense documentation.
Note: This is an expansion on my answer to this question
Depending on the Ad Server you are using.. you would set various Targetting Profiles. Then when you are selling your inventory, you would let advertisers pick which targetting profile they want to buy.
The adserver would generate code for these Placements / Zones. You would program your site to call the right zone depending on the user.