First you have to create a general facebook application:
https://developers.facebook.com/apps
After that, you can add the application (with fan gate logic) as Page Tab
to your site.
Here the official facebook tutorial for page tabs:
https://developers.facebook.com/docs/appsonfacebook/pagetabs/
When a user selects your Page Tab, you will receive the signed_request parameter with one additional parameter, page. This parameter contains a JSON object with an id (the page id of the current page), admin (if the user is a admin of the page), and liked (if the user has liked the page). As with a Canvas Page, you will not receive all the user information accessible to your app in the signed_request until the user authorizes your app.