jonathanleger

msg:1435728 | 7:24 pm on Mar 1, 2004 (gmt 0) |
Excellent! Thanks.
|
sezampicika

msg:1435729 | 7:27 pm on Mar 1, 2004 (gmt 0) |
can someone explain how to install script? Or can someone zip it and put it on some free web server? Thanks
|
scangwinnett

msg:1435730 | 3:33 am on Mar 2, 2004 (gmt 0) |
I would like to include the Javascript code in an include file that is included at the bottom of all of the web pages on my site. On a few pages I don't have the AdSense code, on those pages I get the error: 'document.getElementById(...)' is null or not an object regarding the line: document.getElementById("google_ads_frame").onfocus = hit; (using kaijohannkursch's version of the JS code). What's the syntax of the if statement I need to put around this statement so that it isn't called when the google_ads_frame doesn't exist on the page? Thanks
|
kaijohannkursch

msg:1435731 | 11:24 am on Mar 2, 2004 (gmt 0) |
if (document.getElementById("google_ads_frame")) document.getElementById("google_ads_frame").onfocus = hit But if you are able to choose what pages contain the code and what not... you could include the code only in pages with AdSense. In addition, is strongly recommended inserting the code JUST after the adsense code. If not, some clics will not count.
|
crxchaos

msg:1435732 | 11:31 am on Mar 2, 2004 (gmt 0) |
I am now using the following code. To register a click the document.body.onunload event must trigger, the adsense iframe must have focus and 'go to' must appear in the status bar. This is still not 100% foolproof but is a lot better and I can still test it without actually clicking an ad because of the one bug that remains :) All the AdSense variables are passed to my click counter script as suggested by kaijohannkursch. Also, the 'if (document.getElementById("google_ads_frame"))' statement allows the code to be inserted in all pages, as per scangwinnett's request, without throwing up a javascript error (I hope). function in_adsense() { ad_focus = 1; } function out_adsense() { ad_focus = 0; } function log() { if (ad_focus == 1) { if (window.status.indexOf('go to') == 0) { bug = new Image(); bug.src = 'clicks.php?' + url_array[1] + '&dest=' + window.status.substring(6); } } }
var ad_focus; if (document.getElementById("google_ads_frame")) { url_array = document.getElementById("google_ads_frame").src.split("?"); document.getElementById("google_ads_frame").onfocus = in_adsense; document.getElementById("google_ads_frame").onblur = out_adsense; document.body.onunload = log; }
However, I too seem to be noticing a worrying dominance of IE in my stats as first highlighted by jomaxx. Preliminary tests are showing me the script isn't working on Mozilla or Opera.
|
kaijohannkursch

msg:1435733 | 11:52 am on Mar 2, 2004 (gmt 0) |
Nothing new with that HUGE code. The window.focus() in the hit function makes all the work (it blurs the focus from the adsense, so every click is taken into account).
|
kaijohannkursch

msg:1435734 | 12:14 pm on Mar 2, 2004 (gmt 0) |
Second full day with the script (with some little modifications made) and the script accounted only 1,4% less clicks than the AdSense account.
|
sezampicika

msg:1435735 | 12:29 pm on Mar 2, 2004 (gmt 0) |
Can someone please help me put that script on my site?
|
Noel

msg:1435736 | 1:07 pm on Mar 2, 2004 (gmt 0) |
sezampicika, it's not the script that is the "hard" part! All you need to do is copy the following text and put it under the AdSense code <script language=javascript> function hit(){ window.focus(); if (window.status){ img = new Image(); img.src = 'http://domain.com/tracking.php?ref=' + escape(document.location) + '&title=' + escape(document.title) + '&ad=' + escape(window.status) + '&id=****'; }; }; document.getElementById("google_ads_frame").onfocus = hit; </script> |
| The "hard" part for you I think? will be the logging part in tracking.php So you will need to make a tracking.php page that will write the "ref", "title" and "ad" data to a DB. You will also need some way to read the DB again! Noel
|
sezampicika

msg:1435737 | 1:13 pm on Mar 2, 2004 (gmt 0) |
Can someone send me tracking.php and something about DB?
|
Noel

msg:1435738 | 1:26 pm on Mar 2, 2004 (gmt 0) |
sezampicika, Can someone send me tracking.php and something about DB? |
| The tracking.php will be a custom made file that will access the DB (database), so I'm not sure if it will help you if someone sends you his tracking.php file! You will also need to setup the database yourself! (that is if you want to log the data to a database) Noel
|
trillianjedi

msg:1435739 | 1:33 pm on Mar 2, 2004 (gmt 0) |
As Noel says, it's pretty straightforward to log and track the data, but not if you're not familiar with php or databases. You may have to do a little learning. In a nutshell, it's as simple as collecting the logged data, analysing it, bit of trial and error for correcting false right-clicks etc (if necessary) and then a little web page to display the DB info in a meaningful fashion. Try some of the "learn php and mySQL" type sites. Alternatively, stick around here for a bit. It won't be long until a very good .php script is hammered out on here in the same way the javascript was. I don't think I'll be doing this via a DB, but simply through a text based log file, in the same way that most of the stats software do it for website logfiles. We don't really need queries for what we're doing, just the stats. TJ
|
sezampicika

msg:1435740 | 1:42 pm on Mar 2, 2004 (gmt 0) |
I know how to make DATA base and PHP file :)...
|
Noel

msg:1435741 | 1:45 pm on Mar 2, 2004 (gmt 0) |
trillianjedi, I love to use queries on my DB's. You can do so many nice things with it :-) With one small query I can sort by IP, Ad, Ref or any other data that I log! That's why I'm loggin my AdSense data to a DB! Noel [edited by: Noel at 1:54 pm (utc) on Mar. 2, 2004]
|
Noel

msg:1435742 | 1:48 pm on Mar 2, 2004 (gmt 0) |
I know how to make DATA base and PHP file :)... |
| Well in that case you do not really need the tracking.php file from an other! Just write the "parst" data from the javascript to the DB. Noel
|
trillianjedi

msg:1435743 | 1:56 pm on Mar 2, 2004 (gmt 0) |
Noel, I agree - very powerful stuff DB's - I've done some really useful things with them myself. Don't get me wrong, I was only saying that for the particular purpose we have in mind for using this AdSense script, a flat text file would be sufficient. I just need the clicks logged and displayed in simple fashion (I already have a picture in my head of what I need). As I think I stated before in an earlier post, I think a lot of .php, database, flat text file etc ideas will come out of this thread over the next week or so. There's always more than one way to skin a cat - having lots of options is not a bad thing. I bet there are a deluge of such scripts being built right now. I'm sure 99% of them will be posted up here. Open-source always produces the best material in the long run anyway - look at how the Javascript code got honed from an idea back on post 1 only a few days ago. TJ
|
triumph

msg:1435744 | 5:09 pm on Mar 2, 2004 (gmt 0) |
I don't know PHP from PCP... Ugh, a flat file would be great for me 2. Because like most people, I'm using one adsense acct for multiple sites, it would be awesome just to get simple click information.
|
Noel

msg:1435745 | 5:41 pm on Mar 2, 2004 (gmt 0) |
triumph, You will still need some way (.PHP, .ASP, .CGI, .CFM or maybe even VBS) to write the data from the javascript to the "text" file! In ColdFusion (CFM) the "tracking" file would need something like the following code to append to a text file. <cffile action = "append" file = "C:\log\adsense.txt" output = "#ref# #title# #ad#" > Noel [edited by: Noel at 5:56 pm (utc) on Mar. 2, 2004]
|
trillianjedi

msg:1435746 | 5:45 pm on Mar 2, 2004 (gmt 0) |
Triumph, you're more than welcome to the one we'll be doing, but it may be a week or so as I'll probably leave it to the expert (my partner in crime - he doesn't know about it yet though) and he's busy at the moment (in demand). ;-) TJ
|
triumph

msg:1435747 | 6:31 pm on Mar 2, 2004 (gmt 0) |
"Triumph, you're more than welcome to the one we'll be doing, but it may be a week..." A week? I've waited over a year for G.. A week is a piece of cake!
|
JohnKelly

msg:1435748 | 8:02 pm on Mar 2, 2004 (gmt 0) |
I'm curious as to a couple of the field names in the javascript code: 1) title = escape(document.title) - What should this field contain? 2) id = **** - Should this be the Adsense publisher id or a user-defined code of some sort?
|
kaijohannkursch

msg:1435749 | 8:23 pm on Mar 2, 2004 (gmt 0) |
| title = escape(document.title) - What should this field contain? |
| Obviously the title of the document, for better file recognising (think for instance in this forum urls: [webmasterworld.com...] does not tell much about the content). | id = **** - Should this be the Adsense publisher id or a user-defined code of some sort? |
| A user-defined identificator to identify different ad styles or whatever.
|
jomaxx

msg:1435750 | 8:29 pm on Mar 2, 2004 (gmt 0) |
You can remove the portion of the code that prints out those two items, unless you want them logged for some reason. They weren't included in the previous JS snippets posted.
|
JohnKelly

msg:1435751 | 9:10 pm on Mar 2, 2004 (gmt 0) |
Neat script! I tried it out, but notice that I'm getting repeat clicks in some case to the same ads, often within a few seconds of each other. Is this normal, and could it be caused by the advertiser's site not loading fast enough? Or perhaps another reason?
|
jonathanleger

msg:1435752 | 9:14 pm on Mar 2, 2004 (gmt 0) |
I noticed in my logs that visitors do sometimes click twice (or more), so I setup my script to filter for 'unique' clicks: if the same IP clicked on the same ad in a 24 hour period, the additional clicks are not counted as "unique".
|
AdSenseAdvisor

msg:1435753 | 10:52 pm on Mar 2, 2004 (gmt 0) |
| Something inside me (gut instinct) still wants this revisited by ASA though. |
| I think that the initial request has been buried behind all these great improvements to the code, but I wanted to confirm that this concept is indeed in line with the Terms and Conditions. I would suggest that, if you're passing your confidential information to a third party for logging, you make sure to use due diligence in selecting and trusting such a party. This forum really is a great place for cooperation and information transfer! ASA.
|
trillianjedi

msg:1435754 | 10:57 pm on Mar 2, 2004 (gmt 0) |
Many thanks ASA. Will be putting it into use then. Big thanks to everyone who's offered their code and honed this script into something very useable. TJ
|
kaijohannkursch

msg:1435755 | 11:25 pm on Mar 2, 2004 (gmt 0) |
| Neat script! I tried it out, but notice that I'm getting repeat clicks in some case to the same ads, often within a few seconds of each other |
| Of course server side applications need to filter clicks in some way. I filtered out clicks from the same ip on the same ad in the same hour, and I am very happy with the results. | if you're passing your confidential information to a third party for logging... |
| Yes, that is a problem for hosted scripts. In addition scripts installed in own servers will have a better performance (lighter databases) and a better execution time (no external script is required).
|
freeflight2

msg:1435756 | 12:09 am on Mar 3, 2004 (gmt 0) |
that's a in fact a pretty neat script - but what are you going to do with all the data it's going to collect? it only will list you all the urls you can already see while browsing your own site - and since you don't know how many times each ad/url was shown originally there'll be no way to tell which ads do 'work' for your audience (and even if: are you going to change your site?) Also I am concerned that the additional JS code might slow down the click-thru process or even crash some buggy browsers. In short: I doubt that it's worth the effort.
|
loanuniverse

msg:1435757 | 12:19 am on Mar 3, 2004 (gmt 0) |
| 'unique' clicks: if the same IP clicked on the same ad in a 24 hour period..... |
| I think it might have to do with the user right clicking and then clicking since the difference is at most a couple of seconds.
|
kaijohannkursch

msg:1435758 | 12:27 am on Mar 3, 2004 (gmt 0) |
| and since you don't know how many times each ad/url was shown originally |
| You could always log also the impressions, it's quite easy. In fact the script developed by jonathanleger does that. The thing is that with some accounts the performance would be very poor with that huge data (my case). Also you can check your logs, stats programs, web stats... to check the impressions per file. In any case, the information provided for this kind of scripts is very valuable. You would need only to take a look to some complete stats to realize. | Also I am concerned that the additional JS code might slow down the click-thru process or even crash some buggy browsers |
| That is completely false with a good code. Those scripts does not interfere at all.
|
| This 205 message thread spans 7 pages: < < 205 ( 1 2 3 4 [5] 6 7 ) > > |
|
|