# Android app event app ## Add App Events Manually * Create an AppEventsLogger object using the helper methods to log your events, where this is the Activity your method is in ``` java= AppEventsLogger logger = AppEventsLogger.newLogger(this); ``` * You can then log your event to logger, where AppEventConstants.EVENT_NAME_X is one of the constants shown in the [Standard Events table](https://developers.facebook.com/docs/app-events/reference) or from the [Code Generator](https://developers.facebook.com/docs/app-events/getting-started-app-events-android#code-generator) code: ``` java= /** * This function assumes logger is an instance of AppEventsLogger and has been * created using AppEventsLogger.newLogger() call. */ public void logCompleteRegistrationEvent (String registrationMethod) { Bundle params = new Bundle(); params.putString(AppEventsConstants.EVENT_PARAM_REGISTRATION_METHOD, registrationMethod); logger.logEvent(AppEventsConstants.EVENT_NAME_COMPLETED_REGISTRATION, params); } ``` * **Event Parameters** 1. Each event can be logged with a **valueToSum** and a set of up to 25 parameters. They are passed via a **Bundle** where the key holds the parameter name and the value either a **String** or an **int**. If you provide another type of value that is not compliant such as a **boolean**, the SDK logs a warning to **LogginBehavior.APP_EVENT** 2. Refer to the[ Standard Event Parameters Reference guide](https://developers.facebook.com/docs/app-events/reference#standard-event-parameters) for parameters typically used with standard events. These parameters are intended to provide guidance, however, you can provide your own parameters as well. Your app should log parameters that you are interested in seeing breakdowns for in insights. 3. Do not use "event" as the name of a parameter. Custom parameters with the name "event" will not be logged. Use another name or add a prefix or suffix to the name, such as **my_custom_event** * **Legacy SDK Initialization** * It is **strongly recommended** that you upgrade to the [latest SDK version]https://developers.facebook.com/docs/app-events/upgrade-guide() * It is **strongly recommended** that you upgrade to the [latest SDK version]() * In the Facebook Android SDK v4.18 and earlier, the SDK must be initialized and app activation events logged explicitly. The SDK provides a helper method to log the app activation event. To do this, invoke the SDK's app activation helper once when the application is created. The following code demonstrates how to initialize the SDK and log the app activation event in the **Application class**: ``` java= package com.example.hellofacebook; import android.app.Application; import com.facebook.FacebookSdk; import com.facebook.appevents.AppEventsLogger; public class HelloFacebookSampleApplication extends Application { @Override public void onCreate() { super.onCreate(); FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); } } ``` ### **Test Your Event Logging** 1. Open the [App Ads Helper](https://developers.facebook.com/tools/app-ads-helper/) 2. In **Select an App**, choose your app and choose **Submit** 3. Scroll the bottom and choose **Test Event** 4. Start your app and send an event. The event should appear page ### **Enabling Debug Logs** <p> Enable debug logs to verify App Event usage from the client side. The debug logs contain detailed requests and JSON responses. Enable debug logs by adding the following code after initializing the Facebook Android SDK: </p> ``` java= FacebookSdk.setIsDebugEnabled(true); FacebookSdk.addLoggingBehavior(LoggingBehavior.APP_EVENTS); ``` <p> This is only for debugging purposes. Please disable debug logs before deploying your app to the public. </p>