Luke
Luke

Reputation: 1233

Store Facebook app referrer

I have some Facebook ads and external ads pointing to an app which is sitting on a page tab.

When my app stores some user information, I'd like to also record which ad referred them to the app via some identifier.

I understand $_SERVER['HTTP_REFERER'] is unreliable in most cases, and any parameters passed as a query string (http://www.facebook.com/pages/Test-Page/21814976xxxxxxx?sk=app_25966185xxxxxxx&referrer=advert_1) do not persist.

Is there a way I can accurately determine how a user got to my iframed Facebook app?

Dump of all HTTP request headers on the app:

[Host] => xxxxx.com.dev
[Connection] => keep-alive
[Content-Length] => 522
[Cache-Control] => max-age=0
[Origin] => http://static.ak.facebook.com
[User-Agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1017.2 Safari/535.19
[Content-Type] => application/x-www-form-urlencoded
[Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[Referer] => http://static.ak.facebook.com/platform/page_proxy.php?v=4
[Accept-Encoding] => gzip,deflate,sdch
[Accept-Language] => en-US,en;q=0.8
[Accept-Charset] => ISO-8859-1,utf-8;q=0.7,*;q=0.3
[Cookie] => PHPSESSID=333dea05c7913f549c98599a797d4f71; __utma=75786053.945637676.1327581224.1327924758.1327928159.8; __utmb=75786053.2.10.1327928159; __utmc=75786053; __utmz=75786053.1327928159.8.8.utmcsr=static.ak.facebook.com|utmccn=(referral)|utmcmd=referral|utmcct=/platform/page_proxy.php; fbsr_259661857422740=N5qiJMZV3Rx_oOpluV9fNfy76R98ux45MF9dqe8SFu4.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiIyLkFRQUU1eWRtcU1wWUlhMkYuMzYwMC4xMzI3OTMyMDAwLjUtMTgxOTA5OTAyMXxZZzNWY3ctdE52YVB1cjJQM3g2OFJBSVlnZEUiLCJpc3N1ZWRfYXQiOjEzMjc5MjgxNzYsInVzZXJfaWQiOiIxODE5MDk5MDIxIn0; ci_session=a%3A6%3A%7Bs%3A10%3A%22session_id%22%3Bs%3A32%3A%22ac29210xxxxxx8d1896cecdacc669%22%3Bs%3A10%3A%22ip_address%22%3Bs%3A9%3A%22127.0.0.1%22%3Bs%3A10%3A%22user_agent%22%3Bs%3A118%3A%22Mozilla%2F5.0+%28Macintosh%3B+Intel+Mac+OS+X+10_6_8%29+AppleWebKit%2F535.19+%28KHTML%2C+like+Gecko%29+Chrome%2F18.0.1017.2+Safari%2F535.19%22%3Bs%3A13%3A%22last_activity%22%3Bi%3A1327928158%3Bs%3A9%3A%22user_data%22%3Bs%3A0%3A%22%22%3Bs%3A14%3A%22signed_request%22%3Bs%3A507%3A%22RBHppEnvz_GZwbPA74cZDbFyp3rYr8Tma8yorW3aoUA.eyJ[SNIPPED]%22%3B%7D72d0866c56330f1a75d00d53e44c6aa4

Upvotes: 2

Views: 2662

Answers (1)

Juicy Scripter
Juicy Scripter

Reputation: 25938

You can use app_data parameter to pass additional data to your application working in Page Tab

In addition, your application will also receive a string parameter called app_data as part of signed_request if an app_data parameter was set in the original query string in the URL your tab is loaded on. For the Shop Now link above, that could look like this: "http://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here". You can use that to customize the content you render if you control the generation of the link.

Upvotes: 4

Related Questions