Get Started – Web

This guide shows you how to add App Events to your new or existing app by integrating the Facebook SDK then logging these events.

This Facebook SDK (JS) App Events API has been deprecated and is no longer supported starting July 1, 2022. There are no plans to add new features to this product.

Instead of using FB.AppEvents.LogEvent, we recommend that you send these events through the Meta Pixel.

Step 1: Configure Your Facebook App

Go to the App Dashboard, click My Apps, and create a new app if you don't already have one. Navigate to Settings > Basic to view the App Details Panel with your App ID, your App Secret, and other details about your app.

Set up your app for advertising by adding the following details:

  • App Domains - Provide Google Play Store URL of your app.
  • Privacy Policy URL - Provide a Privacy Policy URL. Required to take your app public.
  • Terms of Service URL - Provide a Terms of Service URL.
  • Platform - Scroll to the bottom of the Settings panel to add the Web Platform. Add the follow details of your app:

Save your changes.

To learn more about adding details to your app, such as an icon or category, visit the App Development docs.

To run ads and measure installs in the Ads Manager, you need to associate at least one Ad Account with your app.

  1. In the app dashboard click Settings > Advanced.
  2. In Authorized Add Account IDs, add your Ad Account IDs. You can get your ad account IDs from your Ads Manager.

Step 3: Integrate the Facebook SDK in Your Website

We provide two ways to integrate the Facebook into your web page, using a Quickstart or adding the SDK manually.

Add the SDK by Using the Quickstart

By using the Quickstart Guide from your App Dashboard to add the Facebook SDK to your Website, the code provided will already include your App ID.

Add the SDK Manually

To add the SDK manually copy and paste the following code but be sure to replace {your-app-id} with your App ID and {version} with the Graph API version your app is using.

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

<script async defer 
  src="https://connect.facebook.net/en_US/sdk.js"></script>
</script>

Step 4: Add App Events

There are three ways events are tracked in your app:

For websites, we recommend triggering the page view event on all pages to ensure accurate user accounts and session durations.

Automatically Logged Events

After you integrate the Facebook SDK into your app, these events are automatically logged.

イベント詳細

アプリのインストール

新しい利用者がアプリを初めてアクティベートしたとき、または特定のデバイスでアプリが初めて起動されたとき。

アプリの起動

利用者がアプリを起動し、Facebook SDKが初期化されてイベントがログに記録されたとき。ただし、最初のアプリの起動イベントから60秒以内に2回目のアプリの起動イベントが発生した場合、2回目のイベントはログ記録されません。

アプリ内購入

Apple App StoreまたはGoogle Playにより処理された購入が完了したとき。ほかの支払いプラットフォームを使用している場合、購入イベントコードを手動で追加する必要があります。

Facebook SDKクラッシュレポート

(Facebookの使用に限定。)

Facebook SDKが原因でアプリがクラッシュした場合、クラッシュレポートが生成されて、アプリの再起動時にFacebookに送られます。このレポートは、ユーザーデータを含んでおらず、FacebookがSDKの品質と安定性を確認する上で役立つものです。このイベントのログ記録をオプトアウトするには、自動でログ記録されるイベントを無効にしてください。

Manually Log Events

To log a custom event, just pass the name of the event as a string:

function onButtonClick() {
  // Add this to a button's onclick handler
  FB.AppEvents.logEvent("{my_app_event}");
}

Event Parameters

Use app event parameters to view breakdowns on your insights you are interested in. The parameters are passed via a Bundle where the key holds the parameter name and the value is either a String or an int. The recommended description for these are guidance only; you can use these parameters or provide your own for whatever makes sense for your app. If you provide another type of value that is not compliant such as a boolean, the SDK logs a warning to LogginBehavior.APP_EVENT.

You can deactivate app events using the Events Manager.

5. Test Your Events

Use Facebook Events Manager

View the most recent events logged by your app or website using the Facebook Events Manager. Choose your app and go to Test Events. Enter your URL to test your events set up.

Use the App Ads Helper Tool

The App Ads Helper allows you to test the app events in your app to ensure that your app is sending events to Facebook.

  1. Open the App Ads Helper.
  2. In Select an App, choose your app and choose Submit.
  3. Scroll down to the bottom and choose Test Events.
  4. Start your app and send an event. The event should appear on the web page.

Learn More

For more information and helpful hints on App Events check out:

  • Best Practices Guide – View a wide variety of sample apps and how each handles App Events.
  • FAQ – Check out our Frequently Asked Questions
  • Ads Manager – View information about your ads.
  • Events Manager – View information about the events you are tracking.