PHP Header Redirect & Google Analyst Tracking

3 replies
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
#analyst #google #header #php #redirect #tracking
  • Profile picture of the author kaido
    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.
    Signature

    {{ DiscussionBoard.errors[1941269].message }}
  • Profile picture of the author senderbot
    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
    Signature
    PornStarStamina is for sale! - Buy the book rights and website! or Just Download the Book For FREE! - Check it out!
    {{ DiscussionBoard.errors[1941818].message }}
  • Profile picture of the author davidsbain
    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.
    {{ DiscussionBoard.errors[1944054].message }}

Trending Topics