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 #90. Build Your Own Web Measurement Application: Commerce Data

Fundamental to online retailers successful with web measurement data is the ability to get non-traffic data into the analysis. In this hack, wel show you how to add the value of a transaction to the mix and tie it back to your referring sources.

In this hack, we'll return to our sample program and demonstrate how to extend it to collect additional data. We'll use the example of measuring revenue, but the same method could be used to collect other types of data. Any data you can access using JavaScript can be passed in the page tag, written to the logfile, and then analyzed by the logfile reader. For example, you could report visitors' screen sizes or visitor segments by the same method.

When a visitor to the web site makes a purchase, we want to record that information. We do this by putting additional JavaScript on the page after the transaction is completed—normally the "thank you" page on the web site.

In this hack, we'll assume that you have some way of accessing the revenue amount using JavaScript. How to do that is very dependent on the shopping cart software you use, and we won't cover it in any detail here. Some shopping carts pass the amount back to you when the transaction is finished, whereas others seem to try and make it as hard as possible. As a last resort, you can approximate by using a fixed amount, such as the amount of the average transaction.

The Code: Page Tag and Tag Processor

Assuming that you ...

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