App Events Best Practices for Strategy Gaming App

This guide is intended to be used as a starting point for your app and should be customized. The example app provides a screen by screen breakdown of the different events and parameters that can be collected. At the end of it, there is a table that lists the recommended events and parameters for your app.

Strategy Gaming App Product and Marketing Objectives

  • Understand the most popular items being purchased in-app as well as hardest levels to complete
  • Retarget users that never completed the tutorial and have not played a level
  • Find new users using lookalikes of high value or frequent purchasers

Example Strategy Game App

ActivatedApp Event

ActivatedApp Event Code Example:

/**
 * For more details, please take a look at:
 * developers.facebook.com/docs/reference/ios/current/class/FBSDKAppEvents
 */
- (void)applicationDidBecomeActive:(UIApplication *)application {    
    [FBSDKAppEvents activateApp];    
}
/**
 * This function assumes logger is an instance of AppEventsLogger and has been
 * created using AppEventsLogger.newLogger() call.
 */
@Override
public void onCreate() {
    super.onCreate();
    FacebookSdk.sdkInitialize(getApplicationContext());
    AppEventsLogger.activateApp(this);
}
/**
 * Include the Facebook namespace via the following code:
 * using Facebook.Unity;
 *
 * For more details, please take a look at:
 * developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent
 */
void Awake ()
{
	if (FB.IsInitialized) {
		FB.ActivateApp();
	} else {
		//Handle FB.Init
		FB.Init( () => {
			FB.ActivateApp();
		});
	}
}

CompletedRegistration Event

CompletedRegistration Event Code Example:

/**
 * For more details, please take a look at:
 * developers.facebook.com/docs/reference/ios/current/class/FBSDKAppEvents
 */
 - (void)logCompletedRegistrationEvent :(NSString*)registrationMethod {

    NSDictionary *params = 
        [[NSDictionary alloc] initWithObjectsAndKeys:
            registrationMethod, FBSDKAppEventParameterNameRegistrationMethod,
            nil];

    [FBSDKAppEvents logEvent: FBSDKAppEventNameCompletedRegistration
        parameters: params];
}
/**
 * This function assumes logger is an instance of AppEventsLogger and has been
 * created using AppEventsLogger.newLogger() call.
 */
public void logCompletedRegistrationEvent (String registrationMethod) {
    Bundle params = new Bundle();
    params.putString(AppEventsConstants.EVENT_PARAM_REGISTRATION_METHOD, registrationMethod);
    logger.logEvent(AppEventsConstants.EVENT_NAME_COMPLETED_REGISTRATION, params);
}
/**
 * Include the Facebook namespace via the following code:
 * using Facebook.Unity;
 *
 * For more details, please take a look at:
 * developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent
 */
public void LogCompletedRegistrationEvent (string registrationMethod) {
    var parameters = new Dictionary<string, object>();
    parameters[AppEventParameterName.RegistrationMethod] = registrationMethod;
    FB.LogAppEvent(
        AppEventName.CompletedRegistration,
        parameters
    );
}

SpentCredits Event

SpentCredits Event Code Example:

/**
 * For more details, please take a look at:
 * developers.facebook.com/docs/reference/ios/current/class/FBSDKAppEvents
 */
 - (void)logSpentCreditsEvent :(NSString*)contentId
    contentType :(NSString*)contentType
    valToSum :(double)totalValue {

    NSDictionary *params = 
        [[NSDictionary alloc] initWithObjectsAndKeys:
            contentId, FBSDKAppEventParameterNameContentID,
            contentType, FBSDKAppEventParameterNameContentType,
            nil];

    [FBSDKAppEvents logEvent: FBSDKAppEventNameSpentCredits
        valueToSum: totalValue
        parameters: params];
}
/**
 * This function assumes logger is an instance of AppEventsLogger and has been
 * created using AppEventsLogger.newLogger() call.
 */
public void logSpentCreditsEvent (String contentId, String contentType, double totalValue) {
    Bundle params = new Bundle();
    params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, contentId);
    params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, contentType);
    logger.logEvent(AppEventsConstants.EVENT_NAME_SPENT_CREDITS, totalValue, params);
}
/**
 * Include the Facebook namespace via the following code:
 * using Facebook.Unity;
 *
 * For more details, please take a look at:
 * developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent
 */
public void LogSpentCreditsEvent (string contentId, string contentType, double totalValue) {
    var parameters = new Dictionary<string, object>();
    parameters[AppEventParameterName.ContentID] = contentId;
    parameters[AppEventParameterName.ContentType] = contentType;
    FB.LogAppEvent(
        AppEventName.SpentCredits,
        (float)totalValue,
        parameters
    );
}

AchievedLevel Event

AchievedLevel Event Code Example:

/**
 * For more details, please take a look at:
 * developers.facebook.com/docs/reference/ios/current/class/FBSDKAppEvents
 */
 - (void)logAchievedLevelEvent :(NSString*)level {

    NSDictionary *params = 
        [[NSDictionary alloc] initWithObjectsAndKeys:
            level, FBSDKAppEventParameterNameLevel,
            nil];

    [FBSDKAppEvents logEvent: FBSDKAppEventNameAchievedLevel
        parameters: params];
}
/**
 * This function assumes logger is an instance of AppEventsLogger and has been
 * created using AppEventsLogger.newLogger() call.
 */
public void logAchievedLevelEvent (String level) {
    Bundle params = new Bundle();
    params.putString(AppEventsConstants.EVENT_PARAM_LEVEL, level);
    logger.logEvent(AppEventsConstants.EVENT_NAME_ACHIEVED_LEVEL, params);
}
/**
 * Include the Facebook namespace via the following code:
 * using Facebook.Unity;
 *
 * For more details, please take a look at:
 * developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent
 */
public void LogAchievedLevelEvent (string level) {
    var parameters = new Dictionary<string, object>();
    parameters[AppEventParameterName.Level] = level;
    FB.LogAppEvent(
        AppEventName.AchievedLevel,
        parameters
    );
}

UnlockedAchievement Event

UnlockedAchievement Event Code Example:

/**
 * For more details, please take a look at:
 * developers.facebook.com/docs/reference/ios/current/class/FBSDKAppEvents
 */
 - (void)logUnlockedAchievementEvent :(NSString*)description {

    NSDictionary *params = 
        [[NSDictionary alloc] initWithObjectsAndKeys:
            description, FBSDKAppEventParameterNameDescription,
            nil];

    [FBSDKAppEvents logEvent: FBSDKAppEventNameUnlockedAchievement
        parameters: params];
}
/**
 * This function assumes logger is an instance of AppEventsLogger and has been
 * created using AppEventsLogger.newLogger() call.
 */
public void logUnlockedAchievementEvent (String description) {
    Bundle params = new Bundle();
    params.putString(AppEventsConstants.EVENT_PARAM_DESCRIPTION, description);
    logger.logEvent(AppEventsConstants.EVENT_UNLOCKED_ACHIEVEMENTS, params);
}
/**
 * Include the Facebook namespace via the following code:
 * using Facebook.Unity;
 *
 * For more details, please take a look at:
 * developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent
 */
public void LogUnlockedAchievementEvent (string description) {
    var parameters = new Dictionary<string, object>();
    parameters[AppEventParameterName.Description] = description;
    FB.LogAppEvent(
        AppEventName.UnlockedAchievement,
        parameters
    );
}

JoinGroup Event

CreateGroup Event

CompletedTutorial Event

CompletedTutorial Event Code Example:

/**
 * For more details, please take a look at:
 * developers.facebook.com/docs/reference/ios/current/class/FBSDKAppEvents
 */
 - (void)logCompletedTutorialEvent :(NSString*)contentId
    success :(BOOL)success {

    NSDictionary *params = 
        [[NSDictionary alloc] initWithObjectsAndKeys:
            contentId, FBSDKAppEventParameterNameContentID,
            [NSNumber numberWithInt:success ? 1 : 0], FBSDKAppEventParameterNameSuccess,
            nil];

    [FBSDKAppEvents logEvent: FBSDKAppEventNameCompletedTutorial
        parameters: params];
}
/**
 * This function assumes logger is an instance of AppEventsLogger and has been
 * created using AppEventsLogger.newLogger() call.
 */
public void logCompletedTutorialEvent (String contentId, boolean success) {
    Bundle params = new Bundle();
    params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, contentId);
    params.putInt(AppEventsConstants.EVENT_PARAM_SUCCESS, success ? 1 : 0);
    logger.logEvent(AppEventsConstants.EVENT_NAME_COMPLETED_TUTORIAL, params);
}
/**
 * Include the Facebook namespace via the following code:
 * using Facebook.Unity;
 *
 * For more details, please take a look at:
 * developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent
 */
public void LogCompletedTutorialEvent (string contentId, bool success) {
    var parameters = new Dictionary<string, object>();
    parameters[AppEventParameterName.ContentID] = contentId;
    parameters[AppEventParameterName.Success] = success ? 1 : 0;
    FB.LogAppEvent(
        AppEventName.CompletedTutorial,
        parameters
    );
}

InitiatedCheckout Event

InitiatedCheckout Event Code Example:

/**
 * For more details, please take a look at:
 * developers.facebook.com/docs/reference/ios/current/class/FBSDKAppEvents
 */
 - (void)logInitiatedCheckoutEvent :(NSString*)contentId
    contentType :(NSString*)contentType
    numItems :(int)numItems
    paymentInfoAvailable :(BOOL)paymentInfoAvailable
    currency :(NSString*)currency
    valToSum :(double)totalPrice {

    NSDictionary *params = 
        [[NSDictionary alloc] initWithObjectsAndKeys:
            contentId, FBSDKAppEventParameterNameContentID,
            contentType, FBSDKAppEventParameterNameContentType,
            [NSNumber numberWithInt:numItems], FBSDKAppEventParameterNameNumItems,
            [NSNumber numberWithInt:paymentInfoAvailable ? 1 : 0], FBSDKAppEventParameterNamePaymentInfoAvailable,
            currency, FBSDKAppEventParameterNameCurrency,
            nil];

    [FBSDKAppEvents logEvent: FBSDKAppEventNameInitiatedCheckout
        valueToSum: totalPrice
        parameters: params];
}
/**
 * This function assumes logger is an instance of AppEventsLogger and has been
 * created using AppEventsLogger.newLogger() call.
 */
public void logInitiatedCheckoutEvent (String contentId, String contentType, int numItems, boolean paymentInfoAvailable, String currency, double totalPrice) {
    Bundle params = new Bundle();
    params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, contentId);
    params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, contentType);
    params.putInt(AppEventsConstants.EVENT_PARAM_NUM_ITEMS, numItems);
    params.putInt(AppEventsConstants.EVENT_PARAM_PAYMENT_INFO_AVAILABLE, paymentInfoAvailable ? 1 : 0);
    params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, currency);
    logger.logEvent(AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT, totalPrice, params);
}
/**
 * Include the Facebook namespace via the following code:
 * using Facebook.Unity;
 *
 * For more details, please take a look at:
 * developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent
 */
public void LogInitiatedCheckoutEvent (string contentId, string contentType, int numItems, bool paymentInfoAvailable, string currency, double totalPrice) {
    var parameters = new Dictionary<string, object>();
    parameters[AppEventParameterName.ContentID] = contentId;
    parameters[AppEventParameterName.ContentType] = contentType;
    parameters[AppEventParameterName.NumItems] = numItems;
    parameters[AppEventParameterName.PaymentInfoAvailable] = paymentInfoAvailable ? 1 : 0;
    parameters[AppEventParameterName.Currency] = currency;
    FB.LogAppEvent(
        AppEventName.InitiatedCheckout,
        (float)totalPrice,
        parameters
    );
}

Purchased Event

Purchased Event Code Example:

/**
 * For more details, please take a look at:
 * developers.facebook.com/docs/reference/ios/current/class/FBSDKAppEvents
 */
 - (void)logPurchasedEvent :(int)numItems
    contentType :(NSString*)contentType
    contentId :(NSString*)contentId
    currency :(NSString*)currency
    valToSum :(double)price {

    NSDictionary *params = 
        [[NSDictionary alloc] initWithObjectsAndKeys:
            [NSNumber numberWithInt:numItems], FBSDKAppEventParameterNameNumItems,
            contentType, FBSDKAppEventParameterNameContentType,
            contentId, FBSDKAppEventParameterNameContentID,
            currency, FBSDKAppEventParameterNameCurrency,
            nil];

    [FBSDKAppEvents logPurchase:price 
          currency: currency
        parameters: params];
}
/**
 * This function assumes logger is an instance of AppEventsLogger and has been
 * created using AppEventsLogger.newLogger() call.
 */
public void logPurchasedEvent (int numItems, String contentType, String contentId, String currency, double price) {
    Bundle params = new Bundle();
    params.putInt(AppEventsConstants.EVENT_PARAM_NUM_ITEMS, numItems);
    params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, contentType);
    params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, contentId);
    params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, currency);
    logger.logPurchase(price, Currency.getInstance(currency),params);
}
/**
 * Include the Facebook namespace via the following code:
 * using Facebook.Unity;
 *
 * For more details, please take a look at:
 * developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent
 */
public void LogPurchasedEvent (int numItems, string contentType, string contentId, string currency, double price) {
    var parameters = new Dictionary<string, object>();
    parameters[AppEventParameterName.NumItems] = numItems;
    parameters[AppEventParameterName.ContentType] = contentType;
    parameters[AppEventParameterName.ContentID] = contentId;
    parameters[AppEventParameterName.Currency] = currency;
    FB.LogPurchase(
	    (float)price,
	    currency,
	    parameters
    );
}

Example Strategy Game App Recommended Events and Parameters

Event Name Predefined Suggested Parameters

App Install

Yes

Launched App

Yes

Completed Registration

Yes

Registration Method

Spent Credits

Yes

Content Type, Level Number

Achieved Level

Yes

Outcome, Level Number, Score, Prizes Earned

Unlocked Achievement

Yes

Achievement Type, Achievement ID, Description

Completed Tutorial

Yes

Description, Content Type, Tutorial Step

Initiated Checkout

Yes

Content Type, Content ID, Currency, valueToSum

Purchased

Yes

Content Type, Content ID, Currency, valueToSum

Purchase Cancelled

Yes

Content Type, Content ID, Currency, valueToSum

Join Group

No

Content Type, Level Number

Create Group

No

Group Name, Group Logo, Group Description, Group Type, Group ID