Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Bidding Directory   High Bandwidth Dedicated Servers   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 02-22-2008, 01:21 PM   #1 (permalink)
Junior Member
 
oddcomments's Avatar
 
Join Date: 01-16-07
Location: USA
Posts: 6
iTrader: 0 / 0%
Latest Blog:
None

oddcomments is liked by many
Track AdSense Clicks in Google CSE?

I'm trying to track only the queries that result in AdSense clicks, but not in all queries. The PHP to MySQL part is easy and I've figured out how to use JavaScript to identify the AdSense ads and triger a function on onClick. I'm stuck at the part with how to call the PHP page with that function.

Anyone have any ideas? Here's what I have so far:
PHP Code:
<script type="text/javascript">
<!--
// THIS CODE MUST BE **AFTER** THE GOOGLE CSE CODE

function adSenseClick() {
    
// WHAT GOES IN HERE?
    // It needs to send: "/AdSenseTracker.php?Query=blue%20widgets&Destination=http://widgets.com/blue.html"
}

function 
load1 () {
    var 
AdSense window.frames["googleSearchFrame"].document.getElementById('pa1');
    if (
AdSense)
        
AdSense.onclick adSenseClick;
}

function 
load2 () {
    var 
AdSense window.frames["googleSearchFrame"].document.getElementById('pa2');
    if (
AdSense)
        
AdSense.onclick adSenseClick;
}

function 
load3 () {
    var 
AdSense window.frames["googleSearchFrame"].document.getElementById('pa3');
    if (
AdSense)
        
AdSense.onclick adSenseClick;
}

function 
load4 () {
    var 
AdSense window.frames["googleSearchFrame"].document.getElementById('pa4');
    if (
AdSense)
        
AdSense.onclick adSenseClick;
}

function 
load5 () {
    var 
AdSense window.frames["googleSearchFrame"].document.getElementById('pa5');
    if (
AdSense)
        
AdSense.onclick adSenseClick;
}

function 
load6 () {
    var 
AdSense window.frames["googleSearchFrame"].document.getElementById('pa6');
    if (
AdSense)
        
AdSense.onclick adSenseClick;
}


function 
doload () {
    if (
document.getElementsByTagName &&
            
document.getElementsByTagName ('body')) {
        
load1 ();
        
load2 ();
        
load3 ();
        
load4 ();
        
load5 ();
        
load6 ();
    }
}

window.onload doload;

//-->
</script> 
oddcomments is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 02-22-2008, 03:06 PM   #2 (permalink)
Junior Member
 
oddcomments's Avatar
 
Join Date: 01-16-07
Location: USA
Posts: 6
iTrader: 0 / 0%
Latest Blog:
None

oddcomments is liked by many
I found the solution:

PHP Code:
function adSenseClick() {
     (new 
Image()).src '/AdSenseTracker.php?Q=bwidgets&D=http://widgets.com/';

...which is the call I started with. The real problem is this:

HERE'S THE REAL PROBLEM...
Google's iframe sets the anchors to "target=_top". I changed the anchor targets in my test Google iframe to "_blank" vs. "_top" and it works great. It definitely seems that the problem lies with the JavaScript not executing before the visitor leaves the page.

Anyone know how to override the anchor target in a frame you have no control over?
.
oddcomments is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
44 Adsense clicks $1.38 John Scott Contextual Networks 73 03-03-2008 11:12 AM
Track the clicks on AdSense Ads reteep Contextual Networks 8 12-20-2007 06:25 AM
* Track clicks on link Madge_T Coding Forum 1 02-12-2007 09:37 AM
Track Google AdSense Clicks Alexandro Contextual Networks 4 10-09-2006 11:25 AM
Best Google Adsense monitoring clicks tools Clanz Contextual Networks 5 05-17-2004 09:27 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 06:48 PM.
© Copyright 2008 V7 Inc