SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    Denver
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Phone number based on referrer?

    Can someone tell me if this is possible? I'd like to have the phone number on my website change depending on where the user comes from. We have several advertisers we work with and I'd like a different phone number to show up (globally accross the site) based on which advertiser the visitor clicks from.

    Is there a way I can achieve this by embedding a "code" in the link? Can someone point me in the right direction to either:

    a) writing the script myself if it's not terribly complicated?

    OR

    b) using a pre-written script?

    I'd like to avoid creating multiple versions of pages since I need the phone number to change globally.

    Cheers!

  2. #2
    Old Fogey mancroft's Avatar
    Join Date
    Oct 2002
    Location
    lost
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    :

    :

  3. #3
    SitePoint Guru gavwvin's Avatar
    Join Date
    Nov 2004
    Location
    Cornwall, UK
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heres a script (I've not tried it) that will get the country (or attempt to) based on the ip of a user ($_SERVER['REMOTE_ADDR']).

    http://www.hotscripts.com/Detailed/38446.html

    Once you've found their country using a script like this you could use appropriate logic to show different phone numbers:
    PHP Code:
    if($country=="US") echo "123-45678";
    else if(
    $country=="UK") echo "98765 432123";
    else echo 
    "1122334455"
    but remember that you cannot depend on the country retrned being absolutely correct. Sometimes it can't find the country (the ISP is a .org or something) or they may be using a ISP from a country other than their own, so don't trust it absolutely. (perhaps have an option to change countries if it got it wrong)

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    Denver
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Thanks for the help! Sorry, maybe I'm not being clear about what I need.

    I basically just need a way to change the phone number of the whole website based on the linking domain that a visitor comes from. Sort of like ad tracking.

    www.advertiser1.com --> 1-800-555-5555
    www.advertiser2.com --> 1-800-545-5544
    www.advertiser3.com --> 1-800-544-1234
    etc.

    Of couse, I need a default phone number if the visitor comes to the site directly, or through a non-advertisement link.

    Thanks!

  5. #5
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Regina, SK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a quick solution, you may want to put this in a database or something depending on the number of referer's you want to handle:

    PHP Code:
    switch ($_SERVER['HTTP_REFERER']) {
      case 
    'www.advertiser1.com':
        
    $number '1-800-555-5555';
      break;
      case 
    'www.advertiser2.com':
        
    $number '1-800-545-5544';
      break;
      case 
    'www.advertiser3.com':
        
    $number '1-800-544-1234';
      break;
      default:
        
    $number '1-800-555-1111';
      break;
    }
    echo 
    $number

  6. #6
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    Denver
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That looks like it will work just fine! I don't have a ton of advertisers to deal with so I can probably get away with hard coding the urls.

    Thanks!


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
  •