Facebook(er) and Authentication Filters

I am looking at this app:

When in facebook, it knows to force the user to add the app when a link
which requires it is appropriate, yet when viewing from
www.mobtropolis.com, it knows to send the visitor to
http://www.mobtropolis.com/account/login.

How does this app do it?!
How are the filters setup?! Where do they go?