1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Track AdSense Clicks With Google Analytics

Discussion in 'Google Analytics' started by digitalpoint, Nov 18, 2005.

  1. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #21
    I haven't tested it myself, but this would probably work (same code for both AdSense and YPN)...

    Let me know if it works (once someone tries it).
    <script type="text/javascript">
    // by Shawn - http://www.digitalpoint.com/~shawn/2005/11/track-adsense-clicks-with-google-analytics.html
    // Put this at the bottom of the page (after the last AdSense block)
    	
    function adsense_click() {
    	if(window.status.indexOf('go to') == 0) {
    		urchinTracker ('/AdSenseClick');
    	}
    }
    
    function ypn_click() {
    	urchinTracker ('/YPNClick');
    }
    	
    var elements;
    if(document.getElementsByTagName) {
    	elements = document.body.getElementsByTagName("IFRAME");
    } else if (document.body.all) {
    	elements = document.body.all.tags("IFRAME");
    } else {
    	elements = Array();
    }
    	
    for(var i = 0; i < elements.length; i++) {
    	if(elements[i].src.indexOf('googlesyndication.com') > -1) {
    		elements[i].onfocus = adsense_click;
    	} else if (elements[i].src.indexOf('overture.com') > -1) {
    		elements[i].onfocus = ypn_click;
    	}
    }
    </script>
    Code (javascript):
     
    digitalpoint, Nov 22, 2005 IP
    mjewel likes this.
  2. mjewel

    mjewel Prominent Member

    Messages:
    6,693
    Likes Received:
    514
    Best Answers:
    0
    Trophy Points:
    310
    #22
    Thanks Shawn, I really appreciate it. I will give it a try and post the results.

    Gee, why is DP my favorite forum?
     
    mjewel, Nov 22, 2005 IP
  3. tresman

    tresman Well-Known Member

    Messages:
    235
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    138
    #23
    Seobook has published a similar code at http://www.seobook.com/archives/001370.shtml which is supossed to work with Firefox.

    I'm not like working on my sites right now, so if someone tries it it would be nice to hear how it worked.
     
    tresman, Nov 23, 2005 IP
  4. Dekker

    Dekker Peon

    Messages:
    4,185
    Likes Received:
    287
    Best Answers:
    0
    Trophy Points:
    0
    #24
    shawn, do you have any idea how to track chitika clicks with analytics?
     
    Dekker, Nov 23, 2005 IP
  5. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #25
    No idea... never looked at Chitika.
     
    digitalpoint, Nov 23, 2005 IP
  6. mjewel

    mjewel Prominent Member

    Messages:
    6,693
    Likes Received:
    514
    Best Answers:
    0
    Trophy Points:
    310
    #26
    YES!! Shawn did it again. Works with YPN :)
     
    mjewel, Nov 24, 2005 IP
  7. Dekker

    Dekker Peon

    Messages:
    4,185
    Likes Received:
    287
    Best Answers:
    0
    Trophy Points:
    0
    #27
    from what I see...no

    Though I may have installed it wrong or am reading the wrong page I dunno
     
    Dekker, Nov 25, 2005 IP
  8. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #28
    Shawn,

    FYI I've noticed that my friend Googlebot is starting to do some interesting things with this code. Given a random page on my site http://example.com/foo/ Googlebot sees a link to http://example.com/foo/googlesyndication.com.

    I'm not sure if there is actually any harm with this, but Googlebot is getting loads of 404's from my sites that are running this code.
     
    tflight, Dec 12, 2005 IP
  9. randymorin

    randymorin Peon

    Messages:
    387
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #29
    I'm getting something similar, but it's not originating from Googlebot.

    This code is still in testing, but if anybody else wants to test it, then feel free.

    Add this

            function chitika_click() 
            {
    	        if(window.status.indexOf('go to') == 0) 
    	        {
    		        urchinTracker ('/ChitikaClick');
    	        }
            }
    Code (markup):
    Change the for loop as such

            for(var i = 0; i < elements.length; i++) 
            {
    	        if(elements[i].src.indexOf('googlesyndication.com') > -1) 
    	        {
    		        elements[i].onfocus = adsense_click;
    	        }
    	        else if (elements[i].src.indexOf('mm.chitika.net') > -1) 
    	        {
    		        elements[i].onfocus = chitika_click;
    	        }
            }
    Code (markup):
    Note: I'm not having any luck. Looks like Chitika took a break (is down).
     
    randymorin, Dec 14, 2005 IP
  10. randymorin

    randymorin Peon

    Messages:
    387
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #30
    In my code immediately above, I think the first snippet should be...

            function chitika_click() 
            {
    	        if(window.status.indexOf('More Info') == 0) 
    	        {
    		        urchinTracker ('/ChitikaClick');
    	        }
            }
    Code (markup):
    I'm still testing it.
     
    randymorin, Dec 14, 2005 IP
    tresman likes this.
  11. randymorin

    randymorin Peon

    Messages:
    387
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #31
    Update, it worked!
     
    randymorin, Dec 21, 2005 IP
  12. amitpagarwal

    amitpagarwal Peon

    Messages:
    375
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #32
    amitpagarwal, Dec 29, 2005 IP
  13. mjewel

    mjewel Prominent Member

    Messages:
    6,693
    Likes Received:
    514
    Best Answers:
    0
    Trophy Points:
    310
    #33
    Thanks for the update. Be sure to post if you get the script to work with firefox.
     
    mjewel, Dec 29, 2005 IP
  14. alephito

    alephito Peon

    Messages:
    197
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #34
    How can you avoid the tracking of clicks in Adlinks? The problem I see is you don't know if the user will finally click in the ad (second click) and the script counts all the first clicks in Adlink Units.
     
    alephito, Jan 16, 2006 IP
  15. theduke56789

    theduke56789 Peon

    Messages:
    207
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #35
    Little late to the game. So what's the best way to track ad units like adlinks in google analytics?

    I'm using the seobook script but don't think it provides ad unit data...
     
    theduke56789, Jan 23, 2006 IP
  16. amitpagarwal

    amitpagarwal Peon

    Messages:
    375
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #36
    amitpagarwal, Jan 23, 2006 IP
  17. theduke56789

    theduke56789 Peon

    Messages:
    207
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #37
    Thanks for the reply ....so does this work with Firefox?
     
    theduke56789, Jan 24, 2006 IP
  18. Riboflavin

    Riboflavin Well-Known Member

    Messages:
    1,091
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    155
    #38
    Thanks for the code guys, and sorry to bump up the old thread but I think it is still relevant, no point in starting a new topic on this subject.

    For me my analytics is reporting more chitika clicks than chitika says I receive, anyone know why?
     
    Riboflavin, Feb 12, 2006 IP
  19. naplesdave

    naplesdave Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #39
    Hi there!

    Beginning the 23rd of February, my Goal %'s are way down, however, actual click throughs are the same. Has anyone else noticed this?

    Again, the number in the G1 or G2 is way off, but clicks on ads are the same.

    Thanks for any input.
    Kind regards,
    Dave Jackson
     
    naplesdave, Feb 26, 2006 IP
  20. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #40
    Yes, I can report seeing the same thing. Around Feb 23 goal tracking went to zero.
     
    tflight, Feb 26, 2006 IP