Monday, September 26, 2005

How to measure if people scroll down a sales letter

I wanted to be able to see how many people were scrolling down my sales letters, and presumably reading the text, so I came up with a cool use of javascript.
 
I found a piece of javascript code that tracks the mouse movement.  When it gets above a certain value on the y-axis, I submit a page in a hidden frame, and insert a database record to log that this person had scrolled down the page.
 
Here's the code for the hidden frame, inserted just above the closing </body> tag.
 
<iframe name="LogFrame" src="" width="0" height= "0"></iframe>
 
Here's the javascript code that tracks the mouse:
 
// THIS PIECE OF CODE TRACKS THE MOUSE, AND FIRES CODE TO DETERMINE WHETHER THE USER HAS SCROLLED DOWN THE PAGE OR NOT
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

//Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
var LogIt = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
 tempX = event.clientX + document.body.scrollLeft
 tempY = event.clientY + document.body.scrollTop
} else {  // grab the x-y pos.s if browser is NS
 tempX = e.pageX
 tempY = e.pageY

if (LogIt == 0 && tempY > 1500)
{  //this is where the frame is submitted with the page that will insert the record into the DB

 window.LogFrame.location.href = "ebook/LogScrollDown.aspx";
 LogIt = 1
}
 
return true
}


This method of scroll-tracking is far from perfect.  If the person is using a non-supported browser, or if cookies are turned off, it won't work.  If the person uses only their down arrows to scroll and never move the mouse, it won't work either.  But, it will work for around 95% of people, and that won't change from sales letter mod-to-mod, so it's a good test.

This technique has been very informative for me so far...

--

>> There are only 10 kinds of people in the world - those that know binary and those that don't.

Labels: ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home

 My Photo
Name: Travis Giggy
Location: Fort Collins, Colorado, US

I am passionate about business on the Internet. This blog is my personal archive of lessons learned while conducting business on the Internet.

I started programming web sites 11 years ago.

In 1997, I started my first Internet business, called Carryout.com. It was an online food ordering service that allowed you to order food from a local restaurant right to your door. At the time, that was pretty cool!

The fire was stoked, and I started learning as much as I could about Internet marketing and copywriting. I became an expert at measuring and testing.

I've been a success and a failure many times over.

Now, a decade later, I still learn every day what it takes to be successful in online business. This blog is how I record those lessons. Since I started this blog, I've learned the value of keeping a written record of my Internet business experiences. As long as I keep learning and growing, I'll keep writing about it.

I doubt I'll ever quit learning.