1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Google Analytics & PHP Header Redirect

Discussion in 'PHP & Perl' started by blackjack, Mar 28, 2010.

  1. blackjack

    blackjack Regular Member

    Joined:
    Nov 23, 2007
    Messages:
    276
    Likes Received:
    51
    Hi

    I am using PHP Header redirect and would like to add GA tracking code. How & where should I put GA code?

    My current PHP redirect has only 3 lines. PHP opening tag, Header/Location redirect and closing tag.

    I want to use PHP redirect because the script rotates three URL and want to see which one has more click/conversion.



    Thanks
     
  2. paytonlowe

    paytonlowe Junior Member

    Joined:
    Dec 24, 2009
    Messages:
    180
    Likes Received:
    58
    Occupation:
    Internet marketer
    Location:
    Cyberspace
    Home Page:
    Add the <body> tag after your redirect code.

    Put the GA code right before the </body> tag at the end of the file.
     
  3. blackjack

    blackjack Regular Member

    Joined:
    Nov 23, 2007
    Messages:
    276
    Likes Received:
    51
    I tried body tag but the script redirects to the new page before anything else get loaded. so it doesn't work.
     
  4. MattDunbar

    MattDunbar Registered Member

    Joined:
    Oct 2, 2008
    Messages:
    72
    Likes Received:
    31
    Occupation:
    Social Media Consultant & Developer
    Location:
    Toronto, ON, Canada
    Use a meta/js redirect, headers are rendered before content, and when a redirect is seen in the header it shouldn't bother downloading the rest of the content.
     
  5. phpmentor

    phpmentor Newbie

    Joined:
    Feb 27, 2010
    Messages:
    17
    Likes Received:
    2
    I would suggest you to make 3 goals instead and track the click to conversion.

    or virtually set the page name for GA on three landing pages to index?id=(1,2,3)