PHP Header Redirect & Google Analyst Tracking

by 3 replies
5
I have this header redirect and would like to add GA tracking code to this. Where should I put GA code ?


<?php

$ref=$_GET(key)

header( 'Location: http://www.mydomain.com/?key=$ref' ) ;

?>

Depending on $ref from url, the script redirect to the relevant URL. How can I add some tracking to track keywords conversions etc?

Thanks
#programming #analyst #google #header #php #redirect #tracking
  • Hm GA is meant to be within body section so you can't use it on this script. Also you can't output any code before header it will throw you an error. So probably your best idea is to do it with javascript or track it by yourself. You can save the keywords and calculate usage percentage.
  • Hi,
    Best way would be to use a normal html meta refresh on a regular webpage. Webpage could be blank - GA would go just before the final body tag like this -

    <html>
    <head>
    <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yoursite.com/">
    </head>
    <body>
    Google analytics here
    </body>
    </html>

    That would work unless theres a specific reason to need to use a php page for the redirect.

    Cheers
    Max
  • check out

    Tracking202 Gateway

    its free and can track keywords from ads to your site to even getting feedback from cpa networks if I remember correctly. I installed it once but it was not so easy. Lots of steps and I dont think I could get the CPA info coming back correctly for some reason.

Next Topics on Trending Feed