Forum Moderators: martinibuster

Message Too Old, No Replies

Updating tracking script to track which ad unit

It could be helpful

         

ari11210

2:48 pm on Oct 29, 2004 (gmt 0)

10+ Year Member



I have just updated my tracking javascript to let me know which of the 3 ad units on my page my visitors are clicking on, this will be helpful in determining if I should reduce the number of ad units on certain pages, or just change their location. I am doing so with this code:

function TrackIt0() {TrackIt(0); }
function TrackIt1() {TrackIt(1); }
function TrackIt2() {TrackIt(2); }

var elements = document.getElementsByTagName("iframe");
for (var i = 0; i < elements.length; i++)
{
if(elements[i].src.indexOf('googlesyndication.com') > -1)
{
//elements[i].onfocus = TrackIt;
if (i==0) elements[i].onfocus = TrackIt0;
if (i==1) elements[i].onfocus = TrackIt1;
if (i==2) elements[i].onfocus = TrackIt2;
}
}


and then changing my TrackIt function to take in a parameter and pass that through to the DB.

Hope this helps,
Aaron

thewonderwall

8:23 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



could you not just use channels to do this?

Llamaman

10:05 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



That's what I was thinking too..... :)

Never_again

12:06 am on Oct 31, 2004 (gmt 0)

10+ Year Member



could you not just use channels to do this?

Yes, you can do that. But if you are already using ari11210's tracking script to create a database of information on your AdSense activity, it would make sense to have this information in that same database. Why take the extra step to import the information from Google?