Tracking the referrer [JS/PHP]

Discussion in 'Programming' started by Wyla, Sep 1, 2007.

  1. #1
    So I'm currently tracking the number of pageviews a page gets with this code on a site that is not my own and does not support php:

    TheirPage1.html contains code
    <img src="mysite.com/track.php?siteid=theirsite">
    Code (markup):
    Track.php then uploads a view for "theirsite" into a mysql db

    What I want is in addition to "theirsite" being sent to my script, I want the url of the page that referred the user to TheirPage1.html

    Example:

    User was on Hoopla.com > Clicked a link that went to TheirPage1.html > img src sets off my script which reads in the referrer

    I've tried reading in the referrer with $_SERVER['HTTP_REFERER'] in my script but it just prints out TheirPage1.html each time.

    What I'm thinking is I need to read in the page referrer in JS and then send that to my php script but I don't know how.

    I need to do it so that the code is all in one section - so no JS in the header and then the img src later on the page.

    Thanks in advance,
    Oleg
     
    Wyla, Sep 1, 2007 IP
  2. James.Blant

    James.Blant Active Member

    Messages:
    250
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    you can't track referers in a page on theirsite .
    you should check it on your site and add it on your image .
    because you reading image from theirpage.html from mysite.com/track.php and in all time your referer is theirpage.html
     
    James.Blant, Sep 2, 2007 IP