Is This Possible? Create URL Identifier Based On HTTP Referrer

5 replies
I would like to add an identifier to the end of any URL if a visitor comes from any page on the facebook.com domain.

It would need to be appended to the target page dynamically.

If they were going to my index.html page, then i would like the URL to be:

...index.html?ID=FB

...or if they were hitting something in the articles folder then...

.../articles/page.html?ID=FB

Multiple people will be placing the inbound links on facebook and I cannot trust them to add the identifier, so I'd like my server to do it on the fly.

I am trying to track anything coming from facebook (mainly conversions LOL) and eventually would like to do this with all social domains (Twitter, LinkedIn etc...)

Thanks for any input!
Oneal
#based #create #http #identifier #referrer #url
  • Profile picture of the author KirkMcD
    Well, you could use .htaccess to check the referrer and rewrite the url or if you are using scripted pages you could add code to check the referrer.
    I'm not an htaccess expert, so I can't give you an example of how to do it, but it can be done.
    {{ DiscussionBoard.errors[3460873].message }}
  • Profile picture of the author andreasnrb
    A htaccess rule could look something like this. Haven't tested it

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://facebook\.com
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule . %{REQUEST_URI}?id=FB [R=301,L]
    {{ DiscussionBoard.errors[3461420].message }}
    • Profile picture of the author Brandon Tanner
      I haven't tested it, but would something like this work?

      <?php
      $referer = $_SERVER['HTTP_REFERER'];
      if ($referer == "http://www.facebook.com")
      {header("Location:http://www.yourwebsite.com?ID=FB");}
      ?>
      Signature

      {{ DiscussionBoard.errors[3465159].message }}
  • Profile picture of the author SteveJohnson
    Originally Posted by Oneal Degrassi View Post

    Multiple people will be placing the inbound links on facebook and I cannot trust them to add the identifier, so I'd like my server to do it on the fly.
    You should be aware that you can't trust BROWSERS to add the referrer.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[3465358].message }}
    • Profile picture of the author stianris
      This should do the trick!

      <?php
      $ref_url = $_SERVER['HTTP_REFERER'];

      if( (preg_match("/facebook.com/", $ref_url, $matches) == 1) ) {

      // You need to add your full URL in here, I am just not allowed to post links yet hehe.
      $link = 'domain.com/?ref=FB';

      }
      else if( (preg_match("/twitter.com/", $ref_url, $matches) == 1) ) {

      $link = 'domain.com/?ref=Twitter';

      }

      header('Location: $link');
      ?>

      Let me know if it works or not.

      Regards,
      Stian
      Signature

      Need help with the technical aspects of your Affiliate Marketing?
      Check out our Free Prosper202 and Site Setup Videos at Affiliate Tech Support!

      {{ DiscussionBoard.errors[3469505].message }}

Trending Topics