Facebook Analytics Getting Started Guide for Games on Facebook

This guide helps you set up Facebook Analytics quickly so you can see data, analyze trends and better understand the behavior of people who use your app.

1. Include the Facebook SDK for JavaScript in Your Game

The following snippet of code will give the basic version of the Facebook SDK for JavaScript where the options are set to their most common defaults. Insert the following code snippet directly after the opening <body> tag on each page you want to use Facebook Analytics. Replace {your-app-id} with the App ID of your game:

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '{your-app-id}',
      xfbml      : true,
      version    : 'v3.2'
    });
    FB.AppEvents.logPageView();
  };

  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "https://connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>
    

You can also configure the SDK with advanced settings.

2. See the Results in the Dashboard

To see events, open Facebook Analytics. Choose your app and navigate to Activity > Event Debugging.
You should see your app launch event. If not, click the refresh button to load the latest events for your app.
Note: Events may take up to 20 minutes to appear in the dashboard.
Once you've verified that your events are being delivered, you're ready to create your first funnel to help you measure conversion for a sequence of events in your app.

Take a Guided Tour of Facebook Analytics

Now that you're logging app events, visit our demo app to take a guided tour of all of the key features that Facebook Analytics offers you and your business.

The demo app does not have an Event Debugging link. This link is only available in apps that you create.

Next Steps

Be sure to check out our other documentation pages for more advanced guides.