GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Any javascript experts ? (https://gfy.com/showthread.php?t=822178)

fluffygrrl 04-15-2008 04:34 PM

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 04-16-2008 05:29 AM

Anybody ?

StuartD 04-16-2008 05:36 AM

Your code looks fine but I don't know enough about google's code to know if that's the proper way to pass along page information to it.

fluffygrrl 04-16-2008 05:54 AM

Well fuck me, I've read the thing 500 times, I still got no clue what's going wrong.

However, this

Code:

<a href="url here" onClick="javascript: pageTracker._trackPageview('track page here');">anchor</a>
Works as expected.

fluffygrrl 04-16-2008 11:23 AM

Bump for this, you never know.

fluffygrrl 04-16-2008 02:43 PM

Final bump.

Dvae 04-16-2008 03:49 PM

I have a feeling this may have something to do with crossframe scripting and security.
http://msdn2.microsoft.com/en-us/lib...28(VS.85).aspx

Second, what errors are you getting?

Do you have the error console installed? If you do this should give you at least a hint what the problem may be.
The error console is a Firefox addon, don't know about IE.
Firebug is also a good addon.

fluffygrrl 04-16-2008 04:52 PM

There's no javascript errors at all.

In principle, there shouldn't be a xfs issue, seeing how my script does not write anything at all, it merely reads iframed content and then calls a function. Where do you see the issue ?

Dvae 04-17-2008 03:21 AM

Quote:

Where do you see the issue ?
I would need a more complete example or link where you have it set up to be able to tell.

fluffygrrl 04-17-2008 10:20 AM

Say http://lolcunts.com

Dvae 04-17-2008 12:39 PM

Quote:

Originally Posted by fluffygrrl (Post 14080041)

First thing is since you have your script in the body it gets called as it loads. and you have the iframe loading after the script runs.
Try flip-flopping that.
I got a different result when I ran it that way.

This could be put in the head tags then use an onload call in the body tags.
Also you can add some alerts like so:
Code:

function trackLC(){
pageTracker._trackPageview('/G3/LC.html');

}

var elements;
if(document.getElementsByTagName) {
        elements = document.body.getElementsByTagName("IFRAME");
alert("if" +elements)
       
}
else if (document.body.all) {
alert("else if")
        elements = document.body.all.tags("IFRAME");
} else {
alert("else")
  elements = array();
}
alert("b4 for")
for(var i = 0; i < elements.length; i++) {
alert("for"+elements[i])
if(elements[i].src.indexOf("xxxblackbook.com") > -1) {
alert("for in if  elements"+elements[i])
elements[i].onfocus = trackLC;
}
}

In this way you can step through it and get some feedback.

Other than that I would need to have a way to know if its working such as the log file (I'm assuming its writing to)


All times are GMT -7. The time now is 09:20 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123