Deconstruct JavaScript Page Tags

Page tagging and the hosted data collection model are relatively new, but becoming more popular. Learn how JavaScript page tags work and make better decisions about deploying them on your site.

JavaScript is a scripting language that is used in web browsers to enable an HTML page to communicate with the visitor’s browser. By understanding JavaScript and how it interacts with variables, you can pass in friendly information like page names, product information, campaign data, or anything else.

How Do Web Measurement Tools Use JavaScript?

Not all web measurement tools collect data the same way, but many use JavaScript to collect information from the visitor’s browser and act as an API to the web server that displays the content. All the popular web browsers on the market use JavaScript, so it is a good medium to use to interact with the browser application and any server-side technology you may have deployed (Active Server Pages, Cold Fusion, etc.).

Since JavaScript resides in the HTML page, it can access variables populated by the application server and the document object. If you are looking at a web page URL, it normally does not contain all the information you would like to collect. For example, only JavaScript can collect the browser resolution of a visitor to your web site.

How a JavaScript Page Tag Works

The basic JavaScript page tag functions in what is loosely referred to as a “round trip”—the embedded code is delivered with the web page, but it ...

Get Web Site Measurement Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.