As Facebook recommends in their Login Flow For Web guide, you can check two important things about the visitor:
- Whether someone is currently logged into Facebook
- Whether someone has previously logged into your app
There are two ways to do this:
- Subscribe to the auth.authResponseChange event
- Call the FB.getLoginStatus function
Either way, you can parse the response for the status of the visitor:
- connected. The person is logged into Facebook, and has logged into your app.
- not_authorized. The person is logged into Facebook, but has not logged into your app.
- unknown. The person is not logged into Facebook, so you don’t know if they’ve logged into your app.
These three statuses correspond to what call to Kissmetrics you should make:
- connected: automatically log in and record the Logged In event upon success.
- not_authorized: prompt the visitor to login with FB.login() and record the Signed Up event upon success.
- unknown: prompt the visitor to login with FB.login(). Upon successful login, fetch more info (with FB.api perhaps) and record Logged In or Signed Up based on the results.
We have not personally worked with the Facebook SDK, so we don’t have a working code example to provide. Please contribute below if you have recommendations!
Updated over 2 years ago