View Single Post
Old 04-15-2008, 04:34 PM  
fluffygrrl
So Fucking Banned
 
Join Date: May 2006
Posts: 2,187
Any javascript experts ?

I have an issue with tracking clicks via google analytics.

Here's the google tracking code :

Code:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("&#37;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>
Here's my homegrown effort at tracking clicks to iframes :

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;
}
}
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.
fluffygrrl is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote