I have a website that hosts content in English and in German: www.mysite.com. I bought a new domain with the same name (www.mysite.de) so that it would redirect to the German content on mysite.com. Here is what I have in the index page on mysite.de:
<?php
header("Location: http://www.mysite.com/index.php?la=de");
exit;
?>
How do I track my Google analytics on mysite.de, before it redirects? I have the Google analytics script, but don't know where to put it.
Asked
Active
Viewed 162 times
0

Moogal
- 107
- 1
- 9
1 Answers
0
By sending the Location:
header, you instantly redirect your viewer to a different website. My suggestion is to read up on the Refresh:
header, show him some information like "You'll be redirected in 5 seconds, if it didn't happen, click here" and in the meantime, also display him the HTML code of the script.

d33tah
- 10,999
- 13
- 68
- 158
-
`header("Location: ")` doesn't terminate the page, therefore the script can be added also when there's `Location` - http://stackoverflow.com/questions/3553698/php-should-i-call-exit-after-calling-location-header – Nikola Feb 03 '14 at 16:16
-
Yes, but I wouldn't be surprised to see the browser trying to optimize the process somehow, not even trying to pull the script. – d33tah Feb 03 '14 at 16:17