Publishes an App Event. App Events allow you to measure the effectiveness of your Facebook app ads and better understand the makeup of users engaging with your app. You can use one of our predefined events such as
AchievedLevel, or use custom events you define.
Log events that could help you understand user behavior and measure engagement coming from your App Ads on Facebook. How often these events occur is reported in aggregate with through Facebook Analytics for Apps.
Users do not need to be logged in with Facebook in order for you to log App Events.
public static void LogAppEvent( string logEventName, float valueToSum, Dictionary<string, object> parameters = null )
The name of the event to log
A number representing a value to be summed when reported
Any parameters needed to describe the event
For many common types of events, constant values are provided in the
Facebook.Unity.AppEventName class. (e.g.
|Name||When to log|
The user has achieved a level in the app.
An app is being activated, typically in the AppDelegate's applicationDidBecomeActive.
The user has entered their payment info.
The user has added an item to their cart. The valueToSum passed should be the item's price.
The user has added an item to their wishlist. The valueToSum passed should be the item's price.
A user has completed registration with the app.
The user has completed a tutorial in the app.
The user has entered the checkout process. The valueToSum passed should be the total price in the cart.
The user has completed a purchase. The
The user has rated an item in the app. The valueToSum passed should be the numeric rating.
A user has performed a search within the app.
The user has spent app credits. The valueToSum passed should be the number of credits spent.
The user has unlocked an achievement in the app.
A user has viewed a form of content in the app.
All parameter name constants are provided in the
Facebook.Unity.AppEventParameterName class. (e.g.
|Parameter Name||Use to specify...|
An ID for the specific piece of content being logged about. Could be an EAN, article identifier, etc., depending on the nature of the app.
A generic content type/family for the logged event, e.g. "music", "photo", "video". Options to use will vary based upon what the app is all about.
ISO-4217 3-letter code for currency used (e.g. "USD", "EUR", "GBP").
A description appropriate to the event being logged. E.g., the name of the achievement unlocked in the
Level parameter, e.g. The level achieved in a
The maximum rating available for the
How many items are being processed for an
Whether payment info is available for the
Method user has used to register for the app, e.g., "Facebook", "email", "Twitter", etc
The string provided by the user for a search operation.
Whether the activity being logged about was successful or not.
A convenience method has been provided to log real-money in-app purchases, which is the most common use of event logging.
public static void LogPurchase( float logPurchase, string currency = null, Dictionary<string, object> parameters = null )
The amount of currency the user spent
The 3-letter ISO currency code
(i.e. US dollars)
Any parameters needed to describe the event. Elements included in this dictionary can't be null
Log that a user has bought, and then spent, some of your in-app currency.
// priceCurrency is a string containing the 3-letter ISO code for the currency // that the user spent, and priceAmount is a float containing the quantity spent; // packageName is a string containing your SKU code for the thing they bought var iapParameters = new Dictionary<string, object>(); iapParameters["mygame_packagename"] = packageName; FB.LogPurchase(priceAmount, priceCurrency, iapParameters); // numGold is the number of in-app currency the user spent in this purchase, // storeItem is a string naming the item the user bought var softPurchaseParameters = new Dictionary<string, object>(); softPurchaseParameters["mygame_purchased_item"] = storeItem; FB.LogAppEvent(Facebook.Unity.AppEventName.SpentCredits, (float)numGold, softPurchaseParameters);
FB.LogAppEvent examples at SDK Examples.