SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Session and cookie-based traffic tracking

    With session.start auto-configured on my webserver, I want to make my surfers sign up before they can access some premium content (selected pages, pdfs, etc.), but I want the session/cookie to store every page they access BEFORE they register, so I can get a complete picture of the content they have accessed. I want the register info plus all surfed pages accessed by that user/cookie/session to be emailed to me upon their departure from my site, whether it be closing the browser, backing up and out, going to a fabvorite, typing in the address bar, etc. Anybody know where I can get started on some scripts like this?

  2. #2
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm...I dunno if it's utterly significant that the information gets emailed to you immediatly when adress bar typed etc. You would get a thousand mails per day maybe.

    Why not record a user's IP, then put all urls visited into this datarow and once the user with ip officially registers the email gets sent. So you only get one mail per new registered user.

  3. #3
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get approximately 500-1500 page requests a day, so it might be a good idea. Only if the user registers would I get that email, in a perfect PHP world. OK, I'll go look for some IP-recognizing functions, and be back with more ????s

  4. #4
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ok, trying to retrieve now....

    OK, I'm not getting emails yet, and it doesn't redirect to the header location, but I'm not getting errors either...
    PHP Code:
    <?php 
        
    if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
                
    $ip getenv("HTTP_CLIENT_IP");
            else if (
    getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
                
    $ip getenv("HTTP_X_FORWARDED_FOR");
            else if (
    getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
                
    $ip getenv("REMOTE_ADDR");
            else if (isset(
    $_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
                
    $ip $_SERVER['REMOTE_ADDR'];
            else
                
    $ip "unknown";
        return(
    $ip);
        
    mail('webmaster@domain.com' 'The IP Is...'$ip);
        
    header "Location: http://www.domain.com/index.htm");
    ?>
    Got this off the php website.... Took the longer one, because it doesn't error out. See
    http://us4.php.net/manual/en/function.getenv.php

  5. #5
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm..make sure the parameters in your mail function are correct..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •