/    Sign up×
Community /Pin to ProfileBookmark

Determine abandoned page statistics

Hello Group,
I am developing an utility that can determine whether a page is abandoned/closed by User while page is still loading. Sometimes an html page takes time to load and because of it is slow, an User might close the page i.e. abandoned.
In my javascript utility,
– On body’s onload method, I am doing following stuff which creates a div element and adds to the body element.
function

show(option)
{
//Remove the elment if it exists.
var tempEle = $(‘_pageloaded’);
if(tempEle)
{
tempEle.remove();
}
var

divLoad = document.createElement(‘div’);
divLoad.id =

‘_pageloaded’;

document.body.appendChild(divLoad);

}

  • On Window.onunload method, I determining whether any element with id ‘_pageloaded’ is there or not and if it is not there then the page is abandoned and logging using servlet.
  • window.onunload = windowload;

    var

    pageloaded = document.getElementById(‘_pageloaded’);

    var msg,isloaded ;

    if(pageloaded)

    {

    isloaded = true;

    }else
    {

    isloaded = false;

    }
    msg = ‘index.html’;
    URL =
    ‘/PageImpressionServlet?page=’ + msg+’&loaded=’+isloaded;

    //alert(URL);
    new Ajax.Request(URL, {
    method: ‘get’,

    Any help/suggestion whether this should work or not?
    Your help would be appreciateed.

  • R
  • to post a comment
    JavaScript

    4 Comments(s)

    Copy linkTweet thisAlerts:
    @Banana_AnandaJul 03.2007 — 1) Is there any reason that pageloaded can't simply be a Javascript variable to start with. What necessitates the creation of an element ?

    2) This may suffer from the usual onload conundrum, depending on your specification. The [i]document[/i] may have loaded, and the user, on a slow connection, may have "used" the page fully before the complete download of all image content - and so before the onload event fires. This may need one of those "document loaded" observers that people like PPK have been developing.
    Copy linkTweet thisAlerts:
    @Banana_AnandaJul 03.2007 — You could cheat. Have an empty, non-displayed element as last element in the doc. Onunload, you check to see whether it exists. This would check document load (minus <body><html>), but ot full image load.
    Copy linkTweet thisAlerts:
    @coolrbauthorJul 04.2007 — This may need one of those "document loaded" observers that people like PPK have been developing.[/quote]

    COuld you give me some link or some information on "document observer" so so that I can try it.
    Copy linkTweet thisAlerts:
    @Banana_AnandaJul 04.2007 — Here's a fairly central link to definition & possible solutions. You'll have to define whether or not it is actually a "problem" for your project.

    http://dean.edwards.name/weblog/2005/09/busted/

    Good luck.
    ×

    Success!

    Help @coolrb spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.28,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...