Hi all,

I have a client that is running WebTrends for a large, enterprise web
site. The way WebTrends works is very simple, and similar to many
other user-tracking software. There is a chunk of WebTrends JavaScript
code (they call it the "SmartSource Data Collector Script"), embedded
in the bottom of every page's source code. This script basically just
gathers several environment variables and then appends a new <img />
tag to the DOM. The source (src) for the image tag is loaded from a
separate web server that is running the WebTrends software. So, when
the WebTrends server receives the request for this tiny image, it logs
the visit to the page in its WebTrends database.

The "SmartSource" script (embedded at the bottom of every web page)
just defines a function and then immediately invokes it, like this:

function dcs_main() {
    // collect client info;
    // create a new <img /> object;
}
dcs_main();  //immediately invoke the above function


The problem I am having is that 99% of the time, IE6 is not finishing
the execution of the WebTrends code, so the special <img /> tag is not
getting appended to the DOM. This is obviously bad because then the
visit to the page is not recorded by WebTrends.

I also have a few simple jQuery DOM manipulations firing on $
(document).ready(). Based on some testing, my theory is that in IE6,
the WebTrends dcs_main() function is beginning its execution but it
never finishes because while it is running, my simple jQuery DOM
manipulations also begin, and the two scripts "collide" when they both
try to change the DOM at the same time. There are never any errors or
anything. I guess I am actually lucky that only IE6 is having this
problem since any browser might have a problem with DOM manipulation
collisions.

One potential solution is to re-invoke the WebTrends dcs_main()
function from inside the $(document).ready() event IF the special
image tag has not already been added to the DOM. That way, if the
dcs_main() function was "short-circuited" by the jQuery scripts (or if
it was somehow not invoked at all), it would definitely be re-invoked
from inside the $(document).ready() event. This "backup measure" could
help to ensure that the <img /> was appended to the DOM no matter what
and that the visit to the page was properly recorded by WebTrends.

I am just wondering if anyone else could recommend a solution with a
different methodology that might not require this kind of "backup
measure" approach. For example, if there was any way to perhaps delay
my jQuery scripts in $(document).ready() from running until after the
WebTrends <img /> tag had been appended to the DOM (which will happen
nearly instantaneously anyway).

Thanks!

Reply via email to