T
Terry
Hi folks.
I was thinking about rolling my own anlaytics service for sites that I
am working on.
I had the idea of using javacript to find all the links on a page and
then attach handlers to them that would have code that would visit
another site that has a database to keep track of hits and duration of
stay at a particular page.
I was wondering if it is possible to visit a site in the background so
that the user goes to the page contained whose url is that of the href
and not the site which will track the visit.
So for example lets say that I have:
<a href="http://www.mysite.com/page1.htm>Page 1</a>
I am hoping that I can write some javascript that will see this link
and attach code to it so that when the link is clicked Page 1 is
accessed as well as its visit is recorded in my tracking service.
So I was hoping my javacript would look through the dom see the link
(<a href..) and attach the function tracker to it (i.e using
addEventListener or attachEvent).
function tracker()
{
//goto http://mytracker.com/track.asp?page=page1.htm
//goto http://www.mysite.com/page1.htm
}
I suppose that I could use location.href or perhaps location.replace
but I thought there might be a better way so that is why I posted
here.
Thanks,
Terry
I was thinking about rolling my own anlaytics service for sites that I
am working on.
I had the idea of using javacript to find all the links on a page and
then attach handlers to them that would have code that would visit
another site that has a database to keep track of hits and duration of
stay at a particular page.
I was wondering if it is possible to visit a site in the background so
that the user goes to the page contained whose url is that of the href
and not the site which will track the visit.
So for example lets say that I have:
<a href="http://www.mysite.com/page1.htm>Page 1</a>
I am hoping that I can write some javascript that will see this link
and attach code to it so that when the link is clicked Page 1 is
accessed as well as its visit is recorded in my tracking service.
So I was hoping my javacript would look through the dom see the link
(<a href..) and attach the function tracker to it (i.e using
addEventListener or attachEvent).
function tracker()
{
//goto http://mytracker.com/track.asp?page=page1.htm
//goto http://www.mysite.com/page1.htm
}
I suppose that I could use location.href or perhaps location.replace
but I thought there might be a better way so that is why I posted
here.
Thanks,
Terry