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 Events Manager

The Events Manager displays the events you send to Facebook Analytics. If this is the first time you launched your app with this code, you may have to wait at least 20 minutes before your events appear.
Note: Events may take up to 20 minutes to appear in the dashboard.

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.