O'Reilly logo

Web Site Measurement Hacks by Eric T. Peterson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack the JavaScript Document Object Model

Understand how the JavaScript Document Object Model is used by many, if not all, tag-based web measurement solutions.

Since most web measurement vendors use the JavaScript Document Object Model (DOM) extensively, you may be concerned about whether your provider’s code interferes with your own JavaScript programming. More importantly, you should be concerned about whether your provider is taking advantage of all the possibilities for data collection the DOM makes available.

Some examples of information the DOM provides include the following.

  • Browser version

  • OS time

  • OS language

  • Monitor resolution

  • Monitor color depth

  • Browser height and width

  • Form analysis

The Document Object Model is a framework used by web browsers and JavaScript to store and access information about a document and, in our case, a web page (Figure 2-16). JavaScript and the JavaScript programmer use the DOM to both gather and place information. From placing the web beacon to gathering information about site visitors, the DOM is central to web analytics.

While Figure 2-16 shows only a small selection of DOM components, it is useful in outlining the structure of the DOM. The window object is the root element and provides access to all other elements. Each object contains functions, properties, events, and/or other objects. JavaScript can be used to access or control each piece of the DOM, as described in the following sections.

Placing the Beacon

As you might expect, the most important piece ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required