homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Google / Google AdSense
Forum Library, Charter, Moderators: incrediBILL & jatar k & martinibuster

Google AdSense Forum

This 205 message thread spans 7 pages: < < 205 ( 1 2 [3] 4 5 6 7 > >     
developing AdSense tracking script
what do you think of tracking AdSense independently?

 9:44 am on Feb 25, 2004 (gmt 0)


I have seen posts that wish detailed AdSense reports such as site level or page level stats.

Currently, we are working on a script to track AdSense impressions and clicks. The script lets you track the stats of sites, pages, referrers, color combinations, ad formats, visitor countries, paid or alternate ads displayed etc.

To remove questions, it conforms to Google TOC completely. No change to AdSense code, no interference.

I want to know your opinions on tracking AdSense independently. Do you personally want to use such a script? What features would you expect?




 5:05 am on Feb 28, 2004 (gmt 0)

David, can you see in your server log if the cgi is being called at all? The parms after the "?" should be in the log.

Tony, is the clicked URL really being caught? I am still skeptical that the window.status field can be interrogated and displayed in this way. If I explicitly set the window.status to some value, I can write code to redisplay it easily. But when the browser displays a URL when I move the mouse over a link, I have not succeeded in writing the simplest script that can display the contents of the status window. It's always blank.


 5:20 am on Feb 28, 2004 (gmt 0)

It would be appreciated if once someone gets a version working, he could post both the code for the page and the server side script that is called. For those of us who have no programming skills.


 6:00 am on Feb 28, 2004 (gmt 0)

David, can you see in your server log if the cgi is being called at all? The parms after the "?" should be in the log.

Nothing in the log. The only other javascript on the page is adsense.

Also, is there a way to set it so you can test it by clicking on the Ads by Google section? (tried changing googlesyndication.com to widget.com)


 9:02 am on Feb 28, 2004 (gmt 0)


I've added the following code just below the AdSense code.

<!--- :: trap --->

<script language=javascript>
function log() {
if (window.status.indexOf('go to') == 0)
bug = new Image();
bug.src = 'log.cfm?ref=' + document.location + '&url=' + window.status.substring(6);
var elements;
elements = document.getElementsByTagName("iframe");
for (var i = 0; i < elements.length; i++){
if(elements[i].src.indexOf('googlesyndication.com') > -1)
elements[i].onfocus = log;

<!--- trap :: --->

(note the window.status.substring(6);)

All that is loged now by the log.cfm file is the URL of the site the AdSense code is running on.

It's the same when I use window.status.substring(5);

The log.cfm file is working fine, as when I access it like "log.cfm?ref= bla bla" it is logging the "bla bla"

Any other suggestions?



 10:18 am on Feb 28, 2004 (gmt 0)

My word, I go to bed, get up in the morning and this code has developed leaps and bounds.

Looking very very good. This thread is the single biggest event in AdSense's history since the launch of AdSense - I'm sure a lot of people haven't actually realised that yet.

It's now absolutely critical that we hear from ASA, soon.


PS Can we stick a time/date stamp in there? Logfile something like the following:-

28/2/04 17:52.03 widgets.com


 10:52 am on Feb 28, 2004 (gmt 0)

Yeah.. I got it to work..

I was only loging the ref= of the bug.src, and forgot the url=.

After adding the url= it worked fine.

I'm now going to make (trying!) a small perl script that will graph the clicks to my MRTG stats page :-)



 12:14 pm on Feb 28, 2004 (gmt 0)

I have taken up jonathonleger's offer to beta test his code, together with a tracking account he has set up to display the data. I have put the code onto several of my pages, and it seems to be working flawlessly - I have access to date/time, source IP, source page and URL, together with summaries and statistics. Unless it emerges that some clicks are being missed for whatever reason (eg browser type), the whole package is there.

Unfortunately (for you, not me) jonathon says he will not be accessible now until Monday, so if you haven't got onto his beta test list yet, you'll need to be patient.

Please don't bombard me with technical questions - I'm a novice at this level of coding. I just stick it in and hope it'll work!


 2:21 pm on Feb 28, 2004 (gmt 0)

Floridasun : I think most people will want to do their own thing rather than disclose their AdSense click info to 3rd party's (no disrespect to Johnathon who's my new hero ;-)).

I suspect running this code through someone else is actually in breach of AdSense TOS too, if you think about it.



 2:29 pm on Feb 28, 2004 (gmt 0)

trillianjedi wrote:
PS Can we stick a time/date stamp in there?

You should be able to generate that using your server-side language of choice. For those using PHP, the following might be useful:

date( 'Y-m-d H:i:s' ) => 2004-02-28 06:37:51
$_SERVER["HTTP_USER_AGENT"] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

I'm sure this information can be passed on as query string variables via JavaScript as well, but I actually program very little JavaScript and prefer to keep client-side code as short as possible.


 2:32 pm on Feb 28, 2004 (gmt 0)


I don't see why you think that my putting some code onto my site (which has already been 'blessed' by AdSenseAdvisor, as it doesn't "modify the AdSense code, or trap the clicks or change the way ads are processed"), and using a third party database to monitor the data that the new code generates would contravene AdSense TOS.


 2:38 pm on Feb 28, 2004 (gmt 0)


From Google Terms and Conditions clause 7 (goto the main google/adsense URL to see in full). The emboldening is mine, not googles.

Confidentiality. You agree not to disclose Google Confidential Information without Google's prior written consent. "Google Confidential Information" includes without limitation: (a) all Google software, technology, programming, technical specifications, materials, guidelines and documentation relating to the Program; (b) click-through rates or other statistics relating to Site performance in the Program provided to You by Google; and (c) any other information designated in writing by Google as "Confidential" or an equivalent designation....

There's no question it's in breach of AdSense TOS. I doubt whether google could find out, however, I wouldn't recommend the risk.

As I said though, most people (rightly) would want to look after this themselves. Disclosing your click data, irrespective of the AdSense TOS, is not the best idea.



 2:48 pm on Feb 28, 2004 (gmt 0)

single biggest event in AdSense's history since the launch of AdSense

Well that's a bit of hyperbole:)

Seriously, I still haven't even bothered to put in any tracking and I had the basic code months ago. The reason - only Google has access to the CPC's.

I'm pretty sure that between my different sites, CPC's vary by more than a factor of 10. While it is nice to know where clicks come from, in order guide my actions (investments of time and money), I need to know revenue.

If I could only have revenue by domain or clicks by page, I would defintely take the former.

Hopefully Google will stop promising and start delivering on report disaggregation.


 2:51 pm on Feb 28, 2004 (gmt 0)

trillianj, note in the text that you bolded that it reads "provided to You by Google" and note the rest of the section beginning "It does not include information that..." that you didn't include in your post.

I'm not a lawyer, but my interpretation of that section is that allowing another party access to the information passed from the JavaScript code is not against the TOS unless Google's interpretation of part (b) of the definition of Google Confidential Information is that a visitor click of a link in the IFRAME generatd by Google's JS is considered "provided to You by Google".

Of course, Google can and has changed the TOS since program inception to address issues that have come up and there's no reason to think they won't do continue to do the same as warranted.

See [google.com...] Section 7 Confidentiality.


 2:53 pm on Feb 28, 2004 (gmt 0)


I still don't think I agree with you on this, although I don't want to make an issue about it. It's obviously a gray area, and hopefully we'll get guidance from "the horses mouth" in due course.

The phrase you have highlighted includes the words 'provided to you by Google'. The statistics we are referring to weren't provided to me by Google.


 2:54 pm on Feb 28, 2004 (gmt 0)


With the clicks per site information, some testing, and the information provided from the adsense account center in respect to earnings, I could get an educated guess as to what is my EPC in each of my sites. In my case, it might take a while since my smallest only has a couple of thousand visitors a month, but you could.


 2:54 pm on Feb 28, 2004 (gmt 0)

Well that's a bit of hyperbole:)

Fair enough - I'll rephrase ;-)

This is the single biggest event *for me* in the history of AdSense......

From this info, if you maintain one site with AdSense, you can directly evaluate CPC to within pretty good accuracy through combination of these stats and the google control panel (and a close eye).

If you run multiple sites with one AdSense account (as we do) the ability to seperate the sites click data is invaluable to us.

This code actually provides what the majority of AdSense publishers have been asking google for since AdSense launched. However you view that, it is at least "a very valuable addition to tools available".

Maybe I should have put it more like that.



 2:58 pm on Feb 28, 2004 (gmt 0)

FloridaSun and RichmondSteve.

Hmmm..... yes, I fully take your points.

The rest of the paragraph was not omitted deliberately.

I'm now not 100% certain. As mentioned by you both, google could change this at any moment of course.

But even as it stands, I won't be risking it until I hear from the horses mouth, as FloridaSun mentioned.

In any event, the main point is, imo, it's not a good idea to disclose click stats to a 3rd party, irrespective of AdSense TOS now or in the future (assuming it's in breach which, as you say, might not be the case).



 2:59 pm on Feb 28, 2004 (gmt 0)

The phrase you have highlighted includes the words 'provided to you by Google'. The statistics we are referring to weren't provided to me by Google.

This is an excellent argument. I wonder if that portion will be edited in the next TOS.

My take, for what isworth, is that ASA has already mentioned that since we are not changing the code it is ok. The fact that someone else "Jonathan" would be involved in the tracking is similar to that of a third party helping you with the running of the website. In my little knowledge of programming, it seems to me that the server-side only gets called after a click in the iframe, right?

If so, Jonathan can not figure out CTR, only clicks. Hard for him to figure out much without this.


 3:06 pm on Feb 28, 2004 (gmt 0)

If so, Jonathan can not figure out CTR, only clicks.

A very good point.

Thinking about it some more - I'll do a quick 180 and side with FloridaSun et al. I now think, as it stands, it is not against AdSense TOS. At least, I would favour more the argument that it isn't than my own original view...

Something inside me (gut instinct) still wants this revisited by ASA though.

Don't know why.



 3:49 pm on Feb 28, 2004 (gmt 0)

I'm surprised this thread hasn't ballooned out of all proportion. This is BIG, BIG, BIG.

monolitik, congrats on starting a brilliant post.

Yidaki, figment88, jonathanleger etc congrats on all the excellent coding.

I'm sure ASA has seen this thread since his last post. I wouldn't be surprised if there is some consulting going on back at the plex ;-) as this is too big a subject for ASA to make any throwaway remarks on (now that it's been shown that the tracking works).

ASA, I hope you come back soon with your OK. Do come back soon.

The only downside with all this is that - one way or another - I see new TOS coming out before long. I can't see them allowing you to disclose stats just because you've collected them yourself and it's not something Google provided.

[edited by: Macro at 3:52 pm (utc) on Feb. 28, 2004]


 3:51 pm on Feb 28, 2004 (gmt 0)

I agree with trillianjedi that it's probably not a good idea to share such data with a 3rd party. I tend to agree with loanuniverse that the information might not actually be considered "disclosed" to the 3rd party so long as the 3rd party isn't looking at and analyzing the data. Even if aggregated a 3rd party logging such data would be privy to a lot of information that could be valuable in terms of determining user click trends, advertiser patterns, etc. It doesn't take much imagination to realize that a 3rd party with clicks, advertiser URLS, timestamps, IPs, user agents and referring pages across 100 sites categorized by industry/type would have information that is quite valuable, even if the 3rd party didn't have impressions or CTR.

And just because the JS code as written only calls a logging function when action is taken within the IFRAME doesn't mean another logging function couldn't be added which would log each page view, thereby giving CTR. And not just CTR, but a more accurate CTR than reported in Google's reports since it would exclude bots, those with JS disabled and with a little work (using a separate server-side script) could account for AA/PSA impressions and clicks. If I wanted the full picture I'd be looking at those details too, but I would do so internally instead of relying on a 3rd party. Nothing personal and I have nothing against anyone here or elsewhere who offers a service to log and report any data like this, but these are my personal opinions.


 4:05 pm on Feb 28, 2004 (gmt 0)

Hi all.
I am on a trip now, and accessing from an Internet Cafe. No time to comment much.

The code fragments posted are on the right track, as I have seen. But do not forget how easy to cheat the click detection algorithm by just focusing the iframe without a click. And do not forget the so many different browser compatibility issues.

This has been a great topic. Thank you all.

Hope to comment more soon.


 4:51 pm on Feb 28, 2004 (gmt 0)

doesn't mean another logging function couldn't be added which would log each page view, thereby giving CTR.

enlighteng me..... would you need to act this function to the code that you put on the pages?

Or could the person hosting the server-side do it all by his lonesome?

BTW, I also think that this is exciting news and might prompt google to make domain segmented stats available soon.

The irony is that having page segmented stats is so much better :)


 5:21 pm on Feb 28, 2004 (gmt 0)

loanuniverse wrote:
enlighteng me..... would you need to act this function to the code that you put on the pages?

Or could the person hosting the server-side do it all by his lonesome?

As a publisher I already track AdSense impressions via PHP code called on each page with AdSense enabled. I simply write data to a MySQL database and then eliminate most bot impressions by IP/user_agent. There are limitations that result in some impressions being counted though the user may not have had JS enabled or the AdSense code may not have loaded, but that's ok for my purposes since I'm really simply interested in relative # of impressions by section of site and trend over time. I als flag AAs (I don't show PSAs) via a script that's executed whenever one of my AAs is loaded since it's important for me to know what pages and sections of my site are showing AAs so I can take action and so that I can calculate true AdSense CTR (by adjusting the AdSense report's impression #s) and effective CPM of AdSense and my affiliate programs displayed in the AAs. If I haven't explained this well feel free to ask and I'll clarify.

If I wanted better accuracy, I'd use JS instead - adding another JS function like log() utilizing an image call to a script which is called on an event like the loading of the page.

There's no need to involve a 3rd party, though if you pasted in server-side code or JS code that a 3rd party provided you it could be logged by a 3rd party.

[edited by: richmondsteve at 5:28 pm (utc) on Feb. 28, 2004]


 5:21 pm on Feb 28, 2004 (gmt 0)

IF the third party provided the external JS to be included in the page, inserting a tracking image to monitor impressions would be trivial and could be done at any time. It would add a huge overhead to their server, though.

For that matter, they could insert cookie tracking as well.

However I definitely think that using a third party for click reporting would be a violation of the TOS.
Plus I would think that most webmasters could do a satisfactory job themselves via their existing log reporting tools.
Plus I would have serious questions about the professionalism of any such service I was using. What happens to my page if the third-party server is down? What happens to my historical stats if they suspend the service? What is being done with the stats collected from my site?


 5:35 pm on Feb 28, 2004 (gmt 0)

I know what AdsenseAdvisor said in this thread about tracking, but has anybody here contacted the Adsense team?


 7:33 pm on Feb 28, 2004 (gmt 0)

how easy to cheat the click detection algorithm by just focusing the iframe without a click

ok, I'd like to be enlightened here.

You can give focus to other types of elements (links, form fields) etc. by tabbing. As far as I know, iFrames are not in the tab order.

You can give focus to elements using JavaScript. That's controlled by the developer, so clearly someone trying to track would not purposly invalidate results.

The container not the frame receives the event handler. I guess if someone clicked at the very edge of the iFrame, a focus might be registered without a click. However, the window status would then be empty, so these could be filtered out.

Similar to last point, I think some browsers only have the actual link be a hyperlink. In IE the whole table cell is clickable. If the adword descriptive text is not clickable on some browsers, then you could give the iFrame focus without a click. However, the status would be then blank and these could be filtered as in the last point.


 8:26 pm on Feb 28, 2004 (gmt 0)

figment88, monolotik is correct that using the JS code that jonathanleger posted, it's possible for a click false-positive. I'm far from a JS expert, but the onfocus event handler isn't actually triggered by a click. Maybe another event handler would be better instead (or in addition to) onfocus.

I discovered such a flaw in the posted code yesterday when I tested using IE6.0 by clicking my mouse button on a link in an IFRAME and noting that it was logged before I released the mouse button. By moving the mouse off of the link and releasing the button it was logged without ever actually following the link. And all of the logged fields were identical to logging for an actual click. In practice I doubt such false-positives would represent a significant percentage of logged records. Since there might be other limitations of the code and it's not improbable that someone could visit your site and generate false-positives on purpose the code might benefit from some modifications or at least publishers being aware of the limitations.


 8:52 pm on Feb 28, 2004 (gmt 0)

I agree you'll get false positives. I think it is more a question of how "easy" it is. A few false postivies, though, are not necessarily much of a problem. As long as they are consistant, you can still compare pages/sites and track changes over time. A scale that always weighs 5 pounds more than the true amount still tracks diet progress.

I just thought monolitik was being more patronizing than helpful.

If monolitik really wants to develop a superior approach and sell it, I say more power to him. I do have issues, though, if he just wants to dangle little tidbits in front of people.

[edited by: figment88 at 8:58 pm (utc) on Feb. 28, 2004]


 8:57 pm on Feb 28, 2004 (gmt 0)

No need to verify, ASA said everything is A OK and he speaks for Google.

This is big, it gives you the ability to verify Google’s statistics for your account. In the past it was Google who said you had a certain CTR and you had to believe it. Now you will know for sure.

As for the post above, I highly doubt anyone will actually Press, move the mouse off the ad, then release the button. Well, maybe one.


 10:12 pm on Feb 28, 2004 (gmt 0)

I'm sure everybody agrees that Google has the technology to provide us real-time stats, per domain and even per page.

They must have GOOD reasons why they don't give us this information.

Apparently, there is now a way to circumvent this problem.

I'm curious how Google will handle this...

This 205 message thread spans 7 pages: < < 205 ( 1 2 [3] 4 5 6 7 > >
Global Options:
 top home search open messages active posts  

Home / Forums Index / Google / Google AdSense
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved