From: Csaba Gabor on
On Jun 21, 7:32 pm, Stefan Weiss <krewech...(a)gmail.com> wrote:
> On 21/06/10 16:18, Asen Bozhilov wrote:
>
> > Thomas 'PointedEars' Lahn wrote:
> >> Asen Bozhilov wrote:
> >> > One possible approach is server side proxy. If you detect click on
> >> > link log statistic and request external page in iframe, otherwise
> >> > request your page on same server. There will be server side script
> >> > which log statistic and relocate to external page. In my opinion that
> >> > is simple solution for your problem.
>
> >> But HTTP proxying will not serve to detect if a new viewport was created to
> >> view the referred resource.  Nor can anything else, reliably.
>
> > Of course, but is that really need? He just not able to detect it.
>
> I agree. That would be the solution I'd prefer if I had to log all link
> clicks, even if the eventual target is an external page. I think that
> was the OP's main point, instead of recognizing when a new tab (or
> window) was opened.

Correct. I have no particular interest in how a user
gets to an external page. I am only interested in
knowing whether s/he went to the external page. The
motivations here being (1) to double check that what
the remote sites report back is not undercounted.
(2) to double check how well my monitoring reflects
reality.

> If that was really important, it might be possible to use history.length
> in some cases:

I didn't mention this explicitly in the original
post, but these product links generally have the
proviso that you may not alter the link, and they
sometimes have robots visit the site to verify
this. I think that's reasonable. The external
product sites certainly have a vested interest in a
standard appearance. Deviation from a standard
appearance/behaviour may lead to confusion and
suspicion on the part of prospective customers.

Furthermore, these product links tend to have a
prohibition against the kind of redirection that
I believe you (and Asen) are implying. But even
if were to trap for their robots and only put in
this redirection when it's not a robot (a very
big if), I still wouldn't want to do this because
the users could see in the status bar that the
link href wasn't directing them to where the link
text was implying they should go. In other words,
I don't want to change the user experience
whatsoever.

And by the way, wouldn't the remote sites detect
the redirection by noting the referer?

>  - let all external links point to a script on your site, for example
>    /tracker?t=http%3A%2F%2Fwww.example.com%2F
>
>  - if JavaScript is enabled, add an additional parameter to this link:
>    /tracker?t=http%3A%2F%2Fwww.example.com%2F&js=1
>
>  - in the 'tracker' script, log the link access and
>    a) without the 'js' parameter, redirect to the link target
>    b) with js=1, send back a small HTML document which reads
>       history.length, sends the result back to the server, and uses
>       history.replace() to direct the visitor to the target site. A
>       length of 1 would suggest that the link has been opened in a new
>       tab/window. You could use other indicators, like the 'Referer'
>       header, cookies, or an additional link parameter to distinguish
>       this case from links which were opened from bookmarks, or directly
>       entered in the address bar.
>
> I don't recommend it. It's not going to work in all cases, and some
> visitors may object (especially if you name the server side script

We are in agreement here.

> 'tracker' ;-), but that's the only thing that comes to my mind if you
> really really need to detect opened tabs.

I have now solved the problem I asked about to my
satisfaction (verified on IE 6, IE 8, FF 1.5) - I
am able to detect navigation to external sites in
JS enabled browsers in most cases that will matter
to me without changing the user experience. I can
differentiate between navigation within the same
window (ie. normal clicks) vs. opening the external
link in either a new tab or new window (but I can't
differentiate between a new tab vs. new window).
The code is compact, and seems to be fairly standard
for this kind of thing. I just hadn't searched under
the right terms initially.

Csaba
From: Csaba Gabor on
On Jun 21, 3:09 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> Csaba Gabor wrote:
> > Thomas 'PointedEars' Lahn wrote:
> >> Csaba Gabor wrote:
> >> > How can I most reliably detect when a link has been clicked to open in
> >> > a new tab or to open in a new window?  I have not found this question
> >> > well adressed in the pages returned up my searches.
>
> >> You have not found anything because you can't do this

Wouldn't it have been better to write, "You can't
reliably do what you want on account of xyz", and
then I would have realized that you had
misunderstood my intent and could have adressed
the technical issues rather than making a detour.

The thing is I know that you know how to do this
because I've seen at least one post from addressing
this topic. And the reason that I didn't find
anything on it was because the main work on this
topic is categorized differently than how I was
approaching it.

> > Your argument, or lack thereof, is not convincing.
> > By saying that I can't do this, you are asserting
> > that there is no detectable change in/on the page
> > that has had such a link clicked.
>
> No, I am asserting that there is no reliable way to detect this, since that
> was your condition.

Incorrect. My problem statement did not use the word
reliable. You have used this word first. I said
most reliably which is substantially different.
And lest it be unclear, I clarified in the third
paragraph of my initial post:

> I don't need a bulletproof solution - I will
> be quite happy if the detection mechanisms works
> a good percentage of the time in recent versions
> of IE and FF.

I want something does not report false positives
and that is better than what I had (which was
nothing).

> > Is that really true?
>
> Your logic is flawed.
>
> >> nor should you try.
>
> > Your pronouncment on my value system does not belong in this forum.
> > "I would not try," would be much more believable, though perhaps
> > not very relevant.
>
> Reading luser responses such as this makes me wonder why I still bother
> investing my free time for an answer, offering my knowledge and experience
> for free.

Hurrah! A bright point in the thread. I have
been wondering the same thing about you, too.
The thing is, you actually have helpful responses
sometimes, and I do appreciate those, but so
often what filters through to me is the vitriol,
dogmatic pronouncements, and especially the
moralizing and assertions about a person's inner
state of mind. So I am supportive of an action
on your part to reduce this type of post in the
future.
From: Thomas 'PointedEars' Lahn on
Csaba Gabor wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Csaba Gabor wrote:
>> > Thomas 'PointedEars' Lahn wrote:
>> >> Csaba Gabor wrote:
>> >> > How can I most reliably detect when a link has been clicked to open
>> >> > in a new tab or to open in a new window? I have not found this
>> >> > question well adressed in the pages returned up my searches.
>> >>
>> >> You have not found anything because you can't do this
>
> Wouldn't it have been better to write, "You can't
> reliably do what you want on account of xyz",

No. That there would be a "most reliable" way implies that there is a
reliable one to begin with. There is not. And if you had paid attention
you would have seen that I am not the only one having that issue with your
question.

>> > Your argument, or lack thereof, is not convincing.
>> > By saying that I can't do this, you are asserting
>> > that there is no detectable change in/on the page
>> > that has had such a link clicked.
>>
>> No, I am asserting that there is no reliable way to detect this, since
>> that was your condition.
>
> Incorrect. My problem statement did not use the word
> reliable. You have used this word first [...]

That is true, you have only used its adverb, and now you go to great lengths
to wind around it. Who you are trying to fool here?

>> > Your pronouncment on my value system does not belong in this forum.
>> > "I would not try," would be much more believable, though perhaps
>> > not very relevant.
>>
>> Reading luser responses such as this makes me wonder why I still bother
>> investing my free time for an answer, offering my knowledge and
>> experience for free.
>
> Hurrah! A bright point in the thread. I have
> been wondering the same thing about you, too.
> [...]

I am sick and tired of your luser attitude. FOAD.
From: SAM on
Le 6/21/10 2:01 PM, Csaba Gabor a �crit :
> On Jun 21, 12:51 pm, SAM <stephanemoriaux.NoAd...(a)wanadoo.fr.invalid>
> wrote:
>>
>> instead of onclick maybe onmousedown, onmouseup ?
>> Or detect the no left-click on mouse down ?
>
> Thanks for this sample code. I am doing on
> onclick what you are doing in onmousedown.
> That gives me actual link openings in the current
> window. However, as I read this code, it doesn't
> cover me for right clicks.

there is nothing to have to do with right-click
since you did it for all mouse buttons with the mouse down
and my example covers any click than the left-one
(whom, by the fact, the right one wich is more difficult to detect as
not the same number with different navigators)


>> <a href="http://google.com"
>> onmousedown="var e = event.wich||event.button;
>> if(e>1) parent.myInvisibleIframe.location='myCountr.php?c='+this.href;"
>> onclick="window.open('myCountr.php?c='+this.href,'view','width=300,height=3�00');
>> return false;">test with google</a>
>>
>> <iframe name="myInvisibleIframe"
>> style="visibility:hidden;width:1px"></iframe>
>>
>> (not tested with IE)

Just you would have to adapt, the file opened in the invisible iframe
would have to be only a very small php to save your clicks where you want.
The iframe has no other object than to do not get a JS error if there is
nothing to receive what the link (the windoxw.open) points to.

Certainly, instead to use an iFrame, wou could use the cookies.

<a href="http://google.com"
onmousedown="setCookie('myClicks',this.href)">google</a>

and no more trouble about left/right clicks, as all of them would be
detected together.

--
sm
From: SAM on
Le 6/21/10 3:12 PM, Thomas 'PointedEars' Lahn a �crit :
> Asen Bozhilov wrote:
>
>> Csaba Gabor wrote:
>>> How can I most reliably detect when a link has been clicked to open in
>>> a new tab or to open in a new window? I have not found this question
>>> well adressed in the pages returned up my searches.
>>>
>>> I am doing some statistics gathering. In particular, I have some
>>> links that point to external websites (they are product links) and I
>>> would like to know when they are clicked, to verify against what the
>>> destination site reports. If they are clicked "normally", to open in
>>> the same window, it is no problem because one just adds an onclick
>>> handler to the link. All my onclick handler does is to send a request
>>> out via an embedded Iframe (so it can be logged by the server), and
>>> this request gets sent before the new page starts to load.
>> One possible approach is server side proxy. If you detect click on
>> link log statistic and request external page in iframe, otherwise
>> request your page on same server. There will be server side script
>> which log statistic and relocate to external page. In my opinion that
>> is simple solution for your problem.
>
> But HTTP proxying will not serve to detect if a new viewport was created to
> view the referred resource. Nor can anything else, reliably.

Since, in fact and if I'd well understood, the purpose is only to know
if a click was made on a link, the problem about to know if same or new
window/tab receives the pointed file is off topic, is a bad question
from the OP.

On my idea a function to tell it (this link was clicked) to the server
in the 'onmousedown' would do the job.

--
sm