com.facebook
Class InsightsLogger

java.lang.Object
  extended by com.facebook.InsightsLogger

public class InsightsLogger
extends Object

The InsightsLogger class allows the developer to log various types of events back to Facebook. In order to log events, the app must create an instance of this class via a newLogger method, and then call the various "log" methods off of that. Note that a Client Token for the app is required in calls to newLogger so apps that have not authenticated their users can still get meaningful user-demographics from the logged events on Facebook.


Method Summary
 void logConversionPixel(String pixelId, double valueOfPixel)
          Log, or "Fire" a Conversion Pixel.
 void logPurchase(BigDecimal purchaseAmount, Currency currency)
          Logs a purchase event with Facebook, in the specified amount and with the specified currency.
 void logPurchase(BigDecimal purchaseAmount, Currency currency, Bundle parameters)
          Logs a purchase event with Facebook, in the specified amount and with the specified currency.
static InsightsLogger newLogger(Context context, String clientToken)
          Build an InsightsLogger instance to log events through.
static InsightsLogger newLogger(Context context, String clientToken, String applicationId)
          Build an InsightsLogger instance to log events through.
static InsightsLogger newLogger(Context context, String clientToken, String applicationId, Session session)
          Build an InsightsLogger instance to log events through.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newLogger

public static InsightsLogger newLogger(Context context,
                                       String clientToken)
Build an InsightsLogger instance to log events through. The Facebook app that these events are targeted at comes from this application's metadata.

Parameters:
context - Used to access the applicationId and the attributionId for non-authenticated users.
clientToken - The Facebook app's "client token", which, for a given appid can be found in the Security section of the Advanced tab of the Facebook App settings found at .
Returns:
InsightsLogger instance to invoke log* methods on.

newLogger

public static InsightsLogger newLogger(Context context,
                                       String clientToken,
                                       String applicationId)
Build an InsightsLogger instance to log events through. Allow explicit specification of an Facebook app to target.

Parameters:
context - Used to access the attributionId for non-authenticated users.
clientToken - The Facebook app's "client token", which, for a given appid can be found in the Security section of the Advanced tab of the Facebook App settings found at
applicationId - Explicitly specified Facebook applicationId to log events against. If null, the applicationId embedded in the application metadata accessible from 'context' will be used.
Returns:
InsightsLogger instance to invoke log* methods on.

newLogger

public static InsightsLogger newLogger(Context context,
                                       String clientToken,
                                       String applicationId,
                                       Session session)
Build an InsightsLogger instance to log events through.

Parameters:
context - Used to access the attributionId for non-authenticated users.
clientToken - The Facebook app's "client token", which, for a given appid can be found in the Security section of the Advanced tab of the Facebook App settings found at
applicationId - Explicitly specified Facebook applicationId to log events against. If null, the applicationId embedded in the application metadata accessible from 'context' will be used.
session - Explicitly specified Session to log events against. If null, the activeSession will be used if it's open, otherwise the logging will happen via the "clientToken" and specified appId.
Returns:
InsightsLogger instance to invoke log* methods on.

logPurchase

public void logPurchase(BigDecimal purchaseAmount,
                        Currency currency)
Logs a purchase event with Facebook, in the specified amount and with the specified currency.

Parameters:
purchaseAmount - Amount of purchase, in the currency specified by the 'currency' parameter. This value will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
currency - Currency used to specify the amount.

logPurchase

public void logPurchase(BigDecimal purchaseAmount,
                        Currency currency,
                        Bundle parameters)
Logs a purchase event with Facebook, in the specified amount and with the specified currency. Additional detail about the purchase can be passed in through the parameters bundle.

Parameters:
purchaseAmount - Amount of purchase, in the currency specified by the 'currency' parameter. This value will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
currency - Currency used to specify the amount.
parameters - Arbitrary additional information for describing this event. Should have no more than 10 entries, and keys should be mostly consistent from one purchase event to the next.

logConversionPixel

public void logConversionPixel(String pixelId,
                               double valueOfPixel)
Log, or "Fire" a Conversion Pixel. Conversion Pixels are used for Ads Conversion Tracking. See https://www.facebook.com/help/435189689870514 to learn more.

Parameters:
pixelId - Numeric ID for the conversion pixel to be logged. See https://www.facebook.com/help/435189689870514 to learn how to create a conversion pixel.
valueOfPixel - Value of what the logging of this pixel is worth to the calling app. The currency that this is expressed in doesn't matter, so long as it is consistent across all logging for this pixel. This value will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).