Tracking page visits

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
 
T

Thomas 'PointedEars' Lahn

Terry said:
[...]
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.

Users will absolutely *love* that. NOT.
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

There is no link so far.
[...]
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).

What about users without the required support?
[...]
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.

Use software that evaluates the server access log instead.


PointedEars
 
T

Terry

Terry said:
[...]
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.

Users will absolutely *love* that.  NOT.
So for example lets say that I have:
I am hoping that I can write some javascript that will see this link

There is no link so far.

I see my error in my link I was missing a quotation mark (").
[...]
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).

What about users without the required support?

By required support do you mean not having javascript enabled?
If that is the case, I would certainly hope that they would because
that can could create a bit of
a problem.
[...]
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.

Use software that evaluates the server access log instead.

PointedEars

I thought that it would be an interesting exercise to see if I could
do it.
Is that not what Google-Analytics is doing for sites that request it's
service.

Anyways, I was wondering is it possible to visit a site in the
background so I don't have to mess around with location.href or
perhaps location.replace.

Are you aware of a way to do that?

Thanks again,
Terry
 
T

Thomas 'PointedEars' Lahn

Terry said:
Terry said:
[...] 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).
What about users without the required support?

By required support do you mean not having javascript enabled?

For this to work, any ECMAScript implementation and sufficient DOM support
would be required.
If that is the case, I would certainly hope that they would because that
can could create a bit of a problem.

ISTM that I pointed out this major flaw in your design decisions before.
[...] 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.
Use software that evaluates the server access log instead. [...]

I thought that it would be an interesting exercise to see if I could do
it. Is that not what Google-Analytics is doing for sites that request
it's service.

Google Analytics is the result of a misguided approach, which is why the
data collected with it is not representative; it can not be.
Anyways, I was wondering is it possible to visit a site in the background
so I don't have to mess around with location.href or perhaps
location.replace.

Are you aware of a way to do that?

If you abandon the aforementioned unreliable approach, you will have to use
a server-side script and the `Location' HTTP header, or URL rewrite. AFAIK,
only the former could involve server-side J(ava)Script.


PointedEars
 
E

El Kabong

Thomas 'PointedEars' Lahn said:
Terry wrote:

Google Analytics is the result of a misguided approach, which is why the
data collected with it is not representative; it can not be.

Please explain.

El
 
T

Thomas 'PointedEars' Lahn

El said:
"Thomas 'PointedEars' Lahn" [...]:
Google Analytics is the result of a misguided approach, which is why the
data collected with it is not representative; it can not be.

Please explain.

Google Analytics does not work without client-side script support, which
is why those hits are not registered. However, there can be a number of
reasons why that support would not be available; it being disabled by the
user is only one of them.


PointedEars
 
T

Terry

El said:
"Thomas 'PointedEars' Lahn" [...]:
Google Analytics is the result of a misguided approach, which is why the
data collected with it is not representative; it can not be.
Please explain.

Google Analytics does not work without client-side script support, which
is why those hits are not registered.  However, there can be a number of
reasons why that support would not be available; it being disabled by the
user is only one of them.

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

Thanks again for responding to my post. I am new to this game and am
truly enjoying it. I have learned alot here and in particular from
you.

I was wondering how is server-side javascript implemented. I have only
seen javascript used on the server when used as the scripting language
within classic asp.

I am assuming that server side javascript will not be apparent to the
user. Perhaps, it might a value in a database.

Thanks,
Terry
 
T

Thomas 'PointedEars' Lahn

Terry said:
El said:
"Thomas 'PointedEars' Lahn" [...]:
Google Analytics is the result of a misguided approach, which is why the
data collected with it is not representative; it can not be.
Please explain.
Google Analytics does not work without client-side script support, which
is why those hits are not registered. However, there can be a number of
reasons why that support would not be available; it being disabled by the
user is only one of them.
[...]

Please trim your quotes. Especially, don't quote signatures unless you
directly refer to them.

http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1Trim
[...]
I was wondering how is server-side javascript implemented. I have only
seen javascript used on the server when used as the scripting language
within classic asp.

I know only two applications of server-side ECMAScript implementations; one
is JScript (.NET) in Microsoft ActiveServer Pages (ASP) (.NET) with Internet
Information Services (IIS), the other is Server-Side JavaScript with a
Netscape Enterprise Server (NES)-compatible Web server (such as the Sun Java
System Web Server, I suppose). The Wikipedia lists more applications:

http://en.wikipedia.org/wiki/Server-side_JavaScript
I am assuming that server side javascript will not be apparent to the
user.

You are correct.
Perhaps, it might a value in a database.

It might use an existing database connection.


PointedEars
 
J

Jeremy J Starcher

By required support do you mean not having javascript enabled? If that
is the case, I would certainly hope that they would because that can
could create a bit of
a problem.

Ouch!

Always plan on what will happen should Javascript not be available.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top