Forum Moderators: martinibuster

Message Too Old, No Replies

A way to track clicks without modifying Adsense code

         

gorfmeister

7:02 pm on Feb 3, 2004 (gmt 0)

10+ Year Member



Any Javascript gurus out that can answer this question?

Can a script be written that will intercept all clicks on a page (or in a section of a page, e.g. <DIV>), perform any operation (e.g. execute a server CGI that would log the click) and then pass it to be processed normally? This script would have to execute before the Adsense script gets run.

If this is possible, this would be a way to track clicks without breaking the TOS. If not, sorry for my wild imagination.

freeflight2

7:17 pm on Feb 3, 2004 (gmt 0)

10+ Year Member



short answer: no
long answer: the google code is within its' own little 'document.root' to which you don't have any access

figment88

7:59 pm on Feb 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you can use javascript to add an onclick handler to all of the iFrames on a page.

the onlick handler could than source a webbug that could log the page title (or other data).

I wrote a little script to do something like this. My laziness combined with promises of "working on reporting by domain" combined with fear of being booted, however, prevented me from implementing it.

gorfmeister

11:39 pm on Feb 3, 2004 (gmt 0)

10+ Year Member



you can use javascript to add an onclick handler to all of the iFrames on a page.

This sounds promising. Would you be willing to post your little script (even if it is incomplete)?

If google names their iFrame, would you be able to add the handler only to that particular frame?

... combined with fear of being booted

I didn't think this would be violation of the TOS (since it only says you cannot modify the script provided by Google), although it does seem like a violation of the spirit of the TOS.

It is kind of a gray area ... I wonder what GoogleAdvisor would say?

richmondsteve

3:50 am on Feb 4, 2004 (gmt 0)

10+ Year Member



Assuming such code would work it may not be a violation of the TOS, but it's probably safe to assume based on their past history that if Google becomes aware of it and doesn't approve of it an update to the TOS would follow.

figment88

6:08 am on Feb 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



what the heck, I take no responsibility.

Here's my little test page.


<head>
<title>here is the page title</title>
</head>
<script>
function log() {
alert(document.activeElement.name);
alert(document.title)
}
</script>

<script>
function attach() {
x = document.getElementsByTagName("iframe")
for(i=0;i<x.length;i++) {
x[i].attachEvent("onfocus",log)
}

}
</script>

<br><br>
<iframe name="ifr" width=300 height=200 src=iframe_content.html></iframe>
<br>
<a href="#" width=300 height=200 onclick="javascript:attach()">Attach Event</a>

Notes
1. For testing the event handler is added with a link. In practice, you would want to use an onLoad handler in the body tag, or put it in the bottom of the page.

2. Also, for testing you will need some file to supply the content of the iFrame (iframe_content.html)

3. I tried attaching the onClick handler which doesn't work for some reason. onFocus seems to do the job.

4. The JavaScript function log, just alerts you that the iframe received focused (i.e was clicked). In actual practice, you would want to use a webbug to log the event.

5. I have no idea as to browser compatability. Heck I'm just a marketer.