I have an issue with tracking clicks via google analytics.
Here's the google tracking code :
Here's my homegrown effort at tracking clicks to iframes :
Now in theory, this script should call the function whenever it sees the sponsor's domain, and the function should increment the goal hits for google analytics.
It is however not werking. Anyone can spot the bug ? My eyes are crossing already.
Here's the google tracking code :
Code:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._initData();
pageTracker._trackPageview();
</script>
Code:
<script type="text/javascript">
function trackLC(){ pageTracker._trackPageview('/G3/LC.html');}
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("xxxblackbook.com") > -1) {
elements[i].onfocus = trackLC;
}
}
It is however not werking. Anyone can spot the bug ? My eyes are crossing already.

Comment