1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Google Analytics: How to use setvar with redirect in PHP?

Discussion in 'Google Analytics' started by susb8383, Jan 21, 2009.

  1. #1
    Hi,

    This is part GA question, part PHP question.

    I'm using Google Analytics. I want to set a user defined variable and then redirect the visitor.

    I have something like this:

    <script type="text/javascript">pageTracker._setVar('testuserdef')</script>
    <?
    header("Location: someurl");
    exit();
    ?>

    The problem is I get the error Warning: Cannot modify header information - headers already sent.

    So I guess calling _setvar is considered setting a header even though nothing is actually displayed.

    Does anyone know how I can do both: set a user-defined variable and then do a redirect?

    TIA.
     
    susb8383, Jan 21, 2009 IP
  2. Zhoog

    Zhoog Peon

    Messages:
    237
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Shouldn't headers be called before anything else on a page?? Couldn't you do it with a window.location script???
     
    Zhoog, Feb 8, 2009 IP