Vectors
Web pages, such as those listed in the preceding example, are instrumented to instruct users' browsers to contact third party servers for a variety of reasons. The following are some of the most common. I've included sample code for each category to highlight a variety of technical means enabling a third party to be contacted.
Advertising Revenue
Webmasters benefit from bringing in advertising revenue to help support their site. As an example, the following is a code snippet that uses an iframe, an HTML technique to embed one web page inside another, to download a banner advertisement from an ad server.
<iframe width="728" height="90" rc="http://g.adspeed.net/ad.php? do=html&zid=XXXXX&wd=728&ht=90&target=_top" frameborder="0" scrolling="no" allowtransparency="true" hspace="0" vspace="0">
Free Content
One of the most tenacious techniques for tracking users as they move about the Web is embedded third-party content. Webmasters embed such content in order to gain free high-quality content, often in the form of media that improve the quality of their site.
Because many sites rely heavily on third-party content, blocking it by default might very well destroy the reason you went to visit the site in the first place.
Embedding third-party content is easy. For example, YouTube even provides embedding code, such as the following, on its video playback pages:
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/rf- s44kTGwQ&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/rf-s44kTGwQ&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
Free Services
Many large online companies provide free services to webmasters as part of their business model. From the perspective of most webmasters this is a great deal. Examples include free web analytics (for example, Google Analytics) and site-based search.
The following is a snippet from a web page that downloads a JavaScript file in support of the Google Analytics service:
<script src="https://www.google-analytics.com/urchin.js" type="text/javascript"></script>
The above examples illustrated a variety of techniques to instruct web browsers to contact third-party servers, including iframes, external JavaScript references, and embedded media objects.
However, these examples are only the tip of the online monitoring iceberg. Click-through tracking (the use of JavaScript to detect which link a user clicked) allows websites to monitor departures from their pages, and referer values passed by web browsing software allow a site to determine visitors' previous locations.
Obfuscated JavaScript is frequently used to make tracking code extremely difficult for humans to understand. Cookies, the old-standby of online user tracking, are still in wide use, of course.