www.webdeveloper.com
Results 1 to 1 of 1

Thread: Tracking ads in a Javascript header.

  1. #1
    Join Date
    Mar 2010
    Posts
    5

    Tracking ads in a Javascript header.

    Hi,

    I wonder if anyone can help me. I have a header I use on my site which has a Javascript code for rotating banner ads. I'd like to try to track the clickthroughs on these ads and have been looking at the methods of doing this in google analytics, but they all seem to be for single links, like this: http://www.imavex.com/tracking-click...analytics.blog

    which then don't work with the links as they are in the banner rather than more standard html links started <a href= etc. I was wondering if anyone knew how I would be able to integrate the analytics code in that link into the banner I have, or of another method I can use to track clicks on the ads.

    Thanks! Hope this makes some sense.

    This is the banner I'm using:

    Code:
    <script type="text/javascript">function initArray() {
    this.length = initArray.arguments.length;
    for (var i = 0; i < this.length; i++) {
    this[i] = initArray.arguments[i];
    }
    }
    link = new initArray(
    "http://www.fitbugs.net/",
    "http://www.themeadows.co.uk/events.php?title=Meadows+Toddler+Tuesday+is+Back%21+&eventid=8",
    "http://sallyslack.com/",
    "http://www.motleyhealth.com/products/low-gi-diet-plan",
    "http://www.talkingtots.info/view-class.asp?ID=Southend",
    "http://www.barracudas.co.uk",
    "http://www.queens-theatre.co.uk/",
    "http://www.starreachacademy.com",
    "http://www.partywithsid.co.uk",
    "http://www.stagecoach.co.uk/chelmsford.html",
    "http://www.themeadows.co.uk/news.php?&newsid=33"
    
    
    
    
    
    
    );
    image = new initArray(
    "http://www.essexmums.org/images/fitbugs4.jpg",
    "http://www.essexmums.org/images/meadows.jpg",
    "http://www.essexmums.org/images/sallyslack.jpg",
    "http://www.essexmums.org/images/motleyhealth.gif",
    "http://www.essexmums.org/images/talkingtotsbanner.jpg",
    "http://www.essexmums.org/images/barracudas.gif",
    "http://www.essexmums.org/images/queenstop.jpg",
    "http://www.essexmums.org/images/starreach.gif",
    "http://www.essexmums.org/images/partywithsid.jpg",
    "http://www.essexmums.org/images/stagecoachbanner.jpg",
    "http://www.essexmums.org/images/kidsclubbanner.jpg"
    
    );
    text = new initArray(
    "Fitbugs",
    "Meadows Toddler Tuesdays",
    "Sally Slack",
    "Low GI",
    "Talking Tots",
    "Barracudas",
    "Queens Theatre",
    "Star Reach",
    "Party with Sid",
    "Stagecoach",
    "Meadows Kids Club"
    
    
    
    
    );
    function getrandom(){
    var core2 = Math.floor(Math.random()*11); // amount of items in array
    
    displaybanner(core2)
    displaybanner(core2)
    }
    function displaybanner(theNum2){
    var ranlink2 = link[theNum2];
    var ranimage2 = image[theNum2];
    var rantext2 = text[theNum2];
    document.getElementById('theImg2').alt=rantext2;
    document.getElementById('theImg2').src=ranimage2;
    document.getElementById('theLink2').href=ranlink2;
    }
    </script><a href="#" target="_blank"
     id="theLink2"><img src="" alt=""
     id="theImg2" border="0"></a>
    <script type="text/javascript"> 
    getrandom();
    setInterval("getrandom()", 22000);
    </script>
    Last edited by weezypops; 08-15-2013 at 01:07 PM. Reason: cat stood on keyboard!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles