The fb_ref variable in a Facebook referrer URL

First I added a Facebook Like button to my website. Then I clicked the button and it added the entry onto my Wall as it should. When I hover my mouse over the link it shows:

However, when I click on it and then view the session variables on my website it shows the following for the referrer:

In my header.php file I have been unable to grab the ref variable that Facebook sends using the following code:

if (isset($ref)) {

$_SESSION['facebook'] = $ref;

Do I need to convert the referral address into one that does not use the % codes first? Is that why it’s not working for me?


$ref would refer to a variable that already exists in the script, not anything input from Facebook.

Shouldn’t you be grabbing something via the query string $_GET[‘’] or a session variable first?

And to be clear, are you using the Legacy function as explained here but not using a javascript handler to process it?