Time-On-Page Goals in Google Analytics & Website Optimizer

September 5, 2007 by Justin Cutroni

Today the Website Optimizer team introduced some new features that will make Optimizer much easier to use. I’m going to defer to the guys at GrokDotCom for coverage on the new features. They got their post up pretty fast and included a snazzy interview with Tom Leung (the Website Optimizer product manager). Please take a moment and check it out.

I’d like to highlight a seemingly minor update to the WO documentation that opened my eyes. Along with the new product features, the WO team published a simple tutorial about how to track time-on-page based conversions. This method can be used to create conversions based on how much time a visitor spends on a page.

How much TIME!Why is this important? Some conversion activities have nothing to do with completing a process. Some conversions measure how engaged a visitor is with a website. While there are many ways to measure engagement, and many different opinions about what engagement is, time spent reading a certain page is one way to measure engagement.

Anyway, the method that the optimizer team published in their support doc can be used in Google Analytics to create time-on-page goals. The secret to the tracking is translating how much time a visitor spends on a page into a pageview. Remember, goal tracking in Google Analytics is based on a pageview. We need to create a pageview that indicates the visitor has been on a page for a certain amount of time.

How it Works

To translate time on page to a pageview we use a nifty JavaScript function called setTimeout(). This function will ‘do something’ after a specified interval of time. We can use setTimeout() to create a pageview after some period of time has elapsed. How do we create pageviews in GA? With urchinTracker().

Here’s the code that will create a pageview after a certain amount of time:


<script>
setTimeout('urchinTracker("/read-pages?page="+
_udl.pathname+_udl.search);', 20000);
</script>

You’ll notice that there are two parts to the setTimeout() function. They’re separated by a comma. The first is urchinTracker(). That’s what will create the pageview after a certain amount of time. The second part is the number 20000. That’s the amount of time that setTimeout() will wait before executing urchinTracker() and thus creating the pageview.

The time is in milliseconds. 1000 milliseconds equals one second. So 10000 milliseconds = 10 seconds.

Place the code, below the standard GA page tag. Once the page loads the timer will start. When the time limit is reached the urchinTracker() function will execute and a pageview will be created for the value passed to urchinTracker(). I’ve used a couple of Google Analytics variable to define the name of the pageview.

udl.pathname is the part of the URL that occurs after the domain extension (.com, .net, etc.) and before any query string parameters (which usually start with a question mark).

_udl.search is the list of query string parameters that appear after the path.

The code will create a pageview for a fictional page named ‘/read-pages’. Part of the fictional page URL will be a query parameter named ‘page’ that stores the name of the page that the visitor was on when the pageview was executed. This setup gives you a lot of flexibility when setting up the goal.

Here’s how the goal would be setup:

Goal Settings for Time on Page Goal

And here are some additional settings I’ve added to this goal:

Additional Settings for Time on Page Goal

The goal is defined as a regular expression. So any pageview that matches ‘/read-page\?page=’ will contribute to the goal total. Using this setup you can create one generic goal called ‘Read Page’ and then use the Goal Verification report to segment the conversions and identify which pages people actually read.

An Example

Let’s say we want to track how many people stay on the following page for 3 minutes:

http://www.epikone.com/blog/2007/08/29/segmenting-members-from-non-members/

First we need to translate minutes to milli seconds:

3 minutes = 180 seconds
1 second = 1000 milliseconds
3 minutes = 180000 milliseconds

Now we’re ready to add the code to the page. Remember, it must go below the standard GA page tag:


<script>
setTimeout('urchinTracker("/read-pages?page="+
_udl.pathname+_udl.search);', 180000);
</script>

After a visitor views the page for 3 minutes the code will create a pageview for:

/read-pages?page=/blog/2007/08/29/segmenting-members-from-non-members/

And a goal conversion will follow.

A Note About Website Optimizer

Obviously this technique will work for tracking conversion in Website Optimizer. The implementation is slightly different. You need to include the account number in the SetTimeout() function. The reason is that the GA code might have a different account number than the Website Optimizer.


<script>
setTimeout('_uacct="UA-XXXXXX-X";
urchinTracker("/read-pages?page="+_udl.pathname+_udl.search);',
20000);
</script>

Conclusion

I can’t believe that I didn’t think of this method before. :) Thanks WO team for posting that very cool article.

Now, what about number of number-of-visit goals or time-on-site goals? I’ve got the number of visits goal tracking figured out and I’m working on a generic time on site. Stay tuned.

Subscribe:

Get Ready for Testing with Website Optimizer

April 4, 2007 by Justin Cutroni

Ok, I’ll bite. I’ll jump on the bandwagon and post about Google Website Optimizer (WO). It seems that everyone is writing about it today so why not one more post? :)

We’ve been using WO for over a year and love it. It’s easy to use, very inexpensive (actually free) and provides tremendous value.

But what I’d like to stress is not the product, but the PROCESS. All of us know that testing is just one phase in our beloved Web Analytics process. Theoretically we should all be testing right now or else we’re just finding problems and not improving visitor experiences. The great thing about Website Optimizer is that it gives us all a robust testing platform.

If you’re new to testing then I urge you to learn about the testing process before diving into Website Optimizer. I know it’s tempting to jump right in and start using the tool, but read about the process first.

Why Process Matters

Testing, more than almost any other part of the web analytics process, needs to be structured. Why? Because if you do not methodically define what you are testing and how you will measure success, you may not know if your test actually worked.

Here’s something I rant about all the time…

Many people believe that all tests are measured using one simple metric: conversion rate. I disagree. While conversion rate may be affected by your test, there are many micro-actions that can, and should, be tested.

For example, let’s say you want to test your add-to-cart button color. You’re testing the color of the button to invoke an action from the visitor. What is the action? To get the visitor to click the button and add the item to the cart. Yes, the action of adding the item to the cart influences the overall conversion rate by moving the visitor through the conversion process, but when you design your test you need to know which action you want to measure. The goal of this test may be to increase the number of visitors who add an item to their cart by 10%, from 50% to 55%.

Where to Start

So, what are some good testing resources? How about Avinash’s blog. He’s got a great post entitled Experimentation and Testing: A Primer. Start there and then head over to FutureNow. They’ve got some great books about how to actually test. You can find two great starter guides at their online store. If you’re already familiar with the testing process then check out the Website Optimizer help section and start reading.

You’ll start to see more posts on this blog about WO and testing. Some posts will focus on the process and some about the tool. Kind of like my approach to web analytics and Google Analytics.

If you’ve been working with WO please feel free to comment, I’d love to hear you’re reaction to the product.

Subscribe: