Adsense Tracker Script

Discussion in 'JavaScript' started by execute, Nov 27, 2005.

  1. #1
    I found an adsense tracker script that was sort of incompatible and modified it to work nice, however i am not sure if it will work good. I tested it and it didn't seem to register into DB. And also i am wondering if there are any hidden disadvantages to this, or a possiblity of getting banned or anything.

    If it will work fine, or something you are free to use it. Hope it helps. (However you do need a tracker.php which you yourself must design in order to add the info to database)

    heres teh script:
    <script>
    var thetitle = "<?php echo $_SERVER['REQUEST_URI']; ?>";
    var ip = "<?php echo $_SERVER['REMOTE_ADDR']; ?>";
    // Just defining some PHP variables like the IP.
    </script>
    <script language="javascript" type="text/javascript">
    var IE, Gecko, Safari, Konqueror;
    // Modified by DesignPlanet.biz
    var agent = navigator.userAgent.toLowerCase();
    IEx = ((agent.indexOf("msie") != -1) && (agent.indexOf("opera") == -1) && (agent.indexOf("webtv") == -1));
    Geckox = (agent.indexOf("gecko") != -1);
    Safarix = (agent.indexOf("safari") != -1);
    Konquerorx = (agent.indexOf("konqueror") != -1);
    var iFr;
    function AdSenseLog(){
    var theAd = "" + escape(window.status.substring(6)) ;
    var format = queryString('format', iFr.src);
    var channel = queryString('channel', iFr.src);
    var bug = new Image();
    bug.src = 'tracker.php?ref=' + document.referrer + '&url=' + theAd + '&title=' + thetitle + '&format=' + format + '&channel=' + channel + '&ip=' + ip;
    }

    function queryString(item, source){
    var itemLoc = source.indexOf(item);
    var newSrc = source.substring(itemLoc);
    var endLoc = newSrc.indexOf("&");
    var lstSrc = newSrc.substring(0, endLoc);
    var itm = lstSrc.substring(item.length+1);
    return itm;
    }
    var elements;
    element = document.getElementsByTagName("iframe");
    for (var i = 0; i < element.length; i++)
    {
    if(element.src.indexOf('googlesyndication.com') > -1){
    if(IEx){
    element.attachEvent("onfocus", AdSenseLog);
    } else {
    element.onfocus = AdSenseLog;
    }
    iFr = element;
    }
    }
    </script>
     
    execute, Nov 27, 2005 IP
  2. WhatiFind

    WhatiFind offline

    Messages:
    1,789
    Likes Received:
    257
    Best Answers:
    0
    Trophy Points:
    180
    #2
    WhatiFind, Nov 27, 2005 IP
  3. execute

    execute Peon

    Messages:
    301
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I dont like google analytics... i find logging into it a hassle :p I have a better stat maker already.
    Is there a way i can track it and add it to a database. Will my code work?
     
    execute, Dec 7, 2005 IP
  4. boussena

    boussena Active Member

    Messages:
    143
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    try this one it's free
    http://www.sourcecodeonline.com/details/adsense_tracking_scripts.html
     
    boussena, Mar 13, 2009 IP
  5. Beaconwebsol

    Beaconwebsol Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    execute if you dont mind. You can please let us know which tracker you use.
    Cause what i believe is that Analytics is the good and shows good tracking.
     
    Beaconwebsol, Mar 15, 2009 IP