problem with javascript and google analytics...

by 4 replies
5
i'm trying to add google anlytics. i added the code as such, but the tracking status isn't active. and idea what i can do to make it active?

my code (yes the page just redirects, but i'd still like analytics):

<html>
<head>
<title>Drug T-shirts</title>
<script type="text/javascript">
<!--
function delayer(){
window.location = "http://www. affiliate link"
}
//-->
</script>



<script type="text/javascript">

google analytics code

</script>




</head>
<body onLoad="setTimeout('delayer()', 1)">


</body>
</html>
#programming #analytics #google #javascript #problem
  • When I setup my Google Analytics, I had to wait for a couple of days for the tracking to become active. Maybe you just need to wait a little longer and see what happens...
    • [1] reply
  • I would try setting up a test page, a very simple HTML page that does nothing except hold the Analytics code. Put it on your site and see if it works correctly.

    Once you confirm it works use the same code on the page you show here. If it doesn't work my guess is that because you call the "delayer" function as soon as the body loads the Analytics code never gets the chance to run.

    With the test page you should be able to determine pretty quickly if that is the case.


    Bill
  • Try placing it before the ending body tag... That's what I always do and it works perfectly... Also, try recopying your analytics code to your site. Some times that fixes that issue as well.

Next Topics on Trending Feed