Payday Loans - Submit articles - Loan - Debt Consolidation - Debt Consolidation

PDA

View Full Version : Problem with placing Google Analytics code


Voimis
Oct 15th 2007, 11:48 am
Hi dudes! I think this is right sub forum for this question because it´s about javascript...

I don´t know where to place the Analytics code because my site just redirects to another one.

Google Analytics page says that it should be placed just before </body> tag but my <head> looks like that so I think browser doesn´t load the Analytics code if it is just before </body>

<head>
<title>kesanekajekku -> gurun testi</title>
<script type="text/javascript">
<!--
window.location = "http://www.example.com/"
//-->
</script>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.example.com">
</head>

So, where I should place it?

Thanks to you guys! :)

Voimis
Oct 16th 2007, 3:00 am
Dudes, anyone?

Thanks a lot!

Lordy
Oct 16th 2007, 4:24 am
just put it anywhere, it'll work anyways :p

ajsa52
Oct 16th 2007, 4:39 am
just put it anywhere, it'll work anyways :p

I don't think so.
IMO if your javascript code executes a redirection (just like window.location = "http://www.example.com/"; ) the following code won't be executed.
So I think you should put the analytics code before that line. That's:


<head>
<title>kesanekajekku -> gurun testi</title>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
<script type="text/javascript">
<!--
_uacct = "your_account";
urchinTracker();
window.location = "http://www.example.com/"
//-->
</script>
</head>

Voimis
Oct 16th 2007, 12:19 pm
I don't think so.
IMO if your javascript code executes a redirection (just like window.location = "http://www.example.com/"; ) the following code won't be executed.
So I think you should put the analytics code before that line. That's:


<head>
<title>kesanekajekku -> gurun testi</title>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
<script type="text/javascript">
<!--
_uacct = "your_account";
urchinTracker();
window.location = "http://www.example.com/"
//-->
</script>
</head>


Thanks to you, I´ll try this.

Is it possible that someones browser doesn´t notify JavaScript redirection which I use (window.location etc..)? I mean do I need to use JavaScript redirect and also the meta-tag redirect if I want permanent redirection?

Thanks to you!

ajsa52
Oct 16th 2007, 3:05 pm
I thought you want that method to know how many people are going to your new site from your previous site.
I you don't want to know that info, IMO the best way to go is through a 301 redirection set on your .htaccess file on your old site redirecting to your new site.

Voimis
Oct 16th 2007, 3:19 pm
I want to know everything what google analytics can provide and that´s why the analytics code in page which just redirects to another one.

Im just thinking which would be the best script type redirection?
freewebs.com doesn´t support PHP so I can´t use it.
Is JavaScript the best option?

ajsa52
Oct 16th 2007, 3:32 pm
If you want info from Google Analytics, then you NEED javascript.
I'm not sure, but if you use the META tag redirection, probably the Analytics code won't be executed.
So IMO your best option is the javascript redirection (window.location assignment) without the META tag redirection.

Voimis
Oct 16th 2007, 4:07 pm
Yes. You´re right.

But is it possible someones browser blocks javascript and then the analytics and redirect code doesn´t work?

ajsa52
Oct 16th 2007, 4:20 pm
Yes, you're right too.
A small percentage of people has javascript disabled on their browsers, and will not be redirected to your new site.
But, you can put a link on the page allowing that people to manually jump to new site.