Web Analytics Made Easy -
StatCounter Redirect popup based on referrer or host IP address - CodingForum

Announcement

Collapse
No announcement yet.

Redirect popup based on referrer or host IP address

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Redirect popup based on referrer or host IP address

    Hi, I want to use something like the "document.referrer" property and also the visitor's IP address to pop up a selection of pages depending on where the visitor links from. I've found lots of scripts that will pop up on a single referrer URL but nothing that will make a selection from a number of pages based on different referrers and source addresses. Alternatively, I could use this to load a different page into an iframe.

    Basically, I want to greet people linking in from selected websites or visiting from selected companies with info that's most relevant to them.

    I should add that if you give me a code snippet I may not know what to do with it but I will do my best!



    many thanks in advance

    Pete

  • #2
    Based on your last sentence, it doesn't sound like you're a coder...

    I would suggest a switch statement or an if/else if/else if clause.

    Why don't you post your sample script that works on one http_referrer. That way we might get a better idea of what you're really talking about, and how to help you out.

    Cheers,
    Sadiq.

    Comment


    • #3
      Hi and thanks for your help - your guess is correct, I'm not really a coder.

      So far, I have got the multiple referrers working although it's a bit clumsy, using javascript, so I'm starting from scratch with PHP based on a recommendation from the JS forum.

      <SCRIPT LANGUAGE="JavaScript"><!--
      if (top.document.referrer == "http://www.ppimk.com/")
      window.open("ppilanding.htm","pop","width=600,height=400,scrollbars=yes,location=no");
      else if (top.document.referrer == "http://www.trainerbase.co.uk/")
      window.open("tblanding.htm","pop","width=600,height=400,scrollbars=yes,location=no");
      else
      window.open("title.htm","pop","width=600,height=400,scrollbars=yes,location=no");
      //--></SCRIPT>

      For instance, I have to specify the exact referrer rather than being able to specify just the domain part, as some sites link from multiple pages.

      Secondly, I would like to include something to also recognise the visitor's IP address.

      And if that wasn't enough, I'm also trying to get a cookie set so the popup only loads once. The current workaround is that it loads in the frameset's navigation bar, so at least it only loads once per visit.

      If you can work through that lot then I am very, very grateful!

      Pete

      Comment


      • #4
        As far as grabbing the domain, check this out:
        http://www.faqts.com/knowledge_base/.../11983/fid/421

        As far as grabbing the user's IP address, check this out:
        http://board.php-princess.net/index....t=ST&f=10&t=14

        The algorithm I would use is as follows:
        Code:
        check the cookie
        if set, do nothing
        else
         grab the domain or visitor's ip address
         do your if else clause to figure out what page to popup
         store the popup page as $popup_page;
         <script>window.open("<?php echo $popup_page; ?>",...);</script>
        Maybe someone will be kind enough to code that up for. Let me know if you have any problems with that.

        BTW. I don't really understand how you decide if you're going to use the referrer or the ip address, but you'll have to specify further there.

        Hope that helps,
        Sadiq.

        Comment


        • #5
          Thankyou- I will check out those links. What I had in mind, structure-wise was:

          if referrer= then popup page 1

          else if referrer=then popup page 2

          else if IP address=then popup page 3

          But I don't know if referrer and host address are on the same level and can be compared in this way.

          thanks again

          Pete

          Comment

          Working...
          X