Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Track AdSense Clicks in Google CSE?
Old 02-22-2008, 04:19 PM Track AdSense Clicks in Google CSE?
oddcomments's Avatar
Novice Talker

Posts: 9
Trades: 0
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> 
__________________

Please login or register to view this content. Registration is FREE

Last edited by oddcomments; 02-22-2008 at 04:22 PM..
oddcomments is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-22-2008, 06:07 PM Re: Track AdSense Clicks in Google CSE?
oddcomments's Avatar
Novice Talker

Posts: 9
Trades: 0
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.

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" instead of "_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?
.
__________________

Please login or register to view this content. Registration is FREE
oddcomments is offline
Reply With Quote
View Public Profile
 
Old 02-28-2008, 07:40 PM Re: Track AdSense Clicks in Google CSE?
Novice Talker

Posts: 5
Trades: 0
thanks for the info
kevencage is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Track AdSense Clicks in Google CSE?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.30424 seconds with 12 queries