Is there a way to track hits to a domain that php redirects to my affiliate site?

Discussion in 'PHP' started by Bearded, Oct 15, 2007.

  1. #1
    Say I have a domain set up and the index.php uses header("Location: http://my.affiliate.site")

    Is there any way to track hits to that with google analytics?

    Mostly I just want to know where traffic is coming from.

    Thanks,
    Joe
     
    Bearded, Oct 15, 2007 IP
  2. ste.richards

    ste.richards Guest

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Somewhere along the line something stores the referrer. I think it's Apache on the last stop.

    So if you click a link at a.com which redirects you to b.com then Apache at b.com will store the referrer somewhere. I know this because I have used a traffic monitor named Webalizer which stores this data.

    Regards,
     
    ste.richards, Oct 15, 2007 IP
  3. Squash

    Squash Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You have 2 ways:
    1. Use Apache and see HTTP referrers. You can use any statistic software (webalizer, awstat etc).

    2. You can use php code and save $_SERVER['HTTP_REFERER'] variable to file or database and after this analyze this information
     
    Squash, Oct 15, 2007 IP
  4. Bearded

    Bearded Peon

    Messages:
    101
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    My host provides webalizer and awstats, but these hits aren't tracking in the Referrals section. It just lists the number of visitors who were 301'd to another site.

    In my php if the index.php is just one line: header(Location: xxx);
    Can I stick a line before that that stores HTTP_REFERRER in a file?
     
    Bearded, Oct 16, 2007 IP
  5. jnestor

    jnestor Peon

    Messages:
    133
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sure. Just be sure you don't output anything or the redirect will break.
     
    jnestor, Oct 16, 2007 IP
  6. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If AWStats cannot read the referrer, I doubt a PHP script could.:confused:

    Another idea is to use unique links for each affiliate, something like "Location: http://my.affiliate.site/?from=1234".

    Jean-Luc
     
    Jean-Luc, Oct 16, 2007 IP
  7. Bearded

    Bearded Peon

    Messages:
    101
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I have a unique link with tracking ID for the affiliate link, but I still can't figure where the traffic is coming from. The other deeper pages on the domain are being tracked just fine, but the pure redirect is not.
     
    Bearded, Oct 16, 2007 IP