How to record a users time on site
Stop loosing visitors! Time on site is one of the most useful metrics. Google website optimizer(GWO) makes it easy to test which design elements yield the highest conversion rate. You can use GWO to see if users spend a certain amount of time on a page, but you can't see which design combinations result in the most time spent on your site or a particular page. To record the time spent on your site you need to:
- Use ajax to send that time to a server-side script the very instance the user leaves that page.
- Use a server-side script (like php or asp) to record that result.
In addition to the time spent on a page I also send which version of the page it is as well as the users current session id so I can track their time spent on my site this visit.
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
include("./connect.php"); //Connect to the database.
mysql_query("INSERT INTO `your_table_name` (`time`) VALUES ('".$_GET["time"]."');"); //Add them to the db.