I use the fololowing code for all links going outisde my website:
if ($_GET["url"])
{
$urll = base64_decode($_GET["url"]);
header("Location: ".$urll);
exit();
}
How can I show the Google Analytic’s tracking code before the user is redirected so the page is tracked?
Could I just use a print statement?
Thanks.
If you wanted to track the hit with GA, then you will have to do something other than a redirect using HTTP headers. With that, you can’t guarantee that the page content will be parsed and executed. I think in most browsers any content would be ignored.
Instead you will need to serve a page (could be blank) and use a javascript and/or meta redirect and place the GA code in there so it gets called prior to the redirect.
Something like this should work: