Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Tracking page visits

Reply
Thread Tools

Tracking page visits

 
 
Terry
Guest
Posts: n/a
 
      01-05-2008
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

 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-05-2008
Terry wrote:
> [...]
> 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
--
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>
 
Reply With Quote
 
 
 
 
Terry
Guest
Posts: n/a
 
      01-05-2008
On Jan 5, 3:36*pm, Thomas 'PointedEars' Lahn <(E-Mail Removed)>
wrote:
> Terry wrote:
> > [...]
> > 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.


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
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-05-2008
Terry wrote:
> [...] Thomas 'PointedEars' Lahn [...] wrote:
>> Terry wrote:
>>> [...] 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
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$(E-Mail Removed)>
 
Reply With Quote
 
El Kabong
Guest
Posts: n/a
 
      01-05-2008

"Thomas 'PointedEars' Lahn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-05-2008
El Kabong wrote:
> "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>
 
Reply With Quote
 
Terry
Guest
Posts: n/a
 
      01-06-2008
On Jan 5, 5:00*pm, Thomas 'PointedEars' Lahn <(E-Mail Removed)>
wrote:
> El Kabong wrote:
> > "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
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-06-2008
Terry wrote:
> [...] Thomas 'PointedEars' Lahn [...] wrote:
>> El Kabong wrote:
>>> "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_not...s.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
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
 
Reply With Quote
 
Jeremy J Starcher
Guest
Posts: n/a
 
      01-08-2008
On Sat, 05 Jan 2008 12:50:24 -0800, Terry wrote:

> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Visits Steve ASP .Net 2 11-14-2008 01:16 AM
maximum visits to a web site or page at same time fulio pen HTML 9 09-28-2007 10:22 PM
search robots visits or doesn`t visit this page K. HTML 4 09-14-2007 08:08 AM
Tracking Someone Tracking Me Edw. Peach Computer Security 4 07-07-2005 05:50 PM
document.referrer question for tracking hits and visits goks Javascript 7 05-30-2004 01:16 AM



Advertisments