public class CustomMonetizationEventBuilder extends MonetizationEventBuilder
The example below demonstrates how to create a monetization event after you receive a purchase confirmation from the IAP framework you are using. You are responsible for storing and making sure that the bare minimum attributes required to build a Custom Purchase Event are available for use at this time. Note that the builder will maintain the values of its internal variables between builds.
Example:
// get the event client from your MobileAnalyticsManager instance
EventClient eventClient = mobileAnalyticsManager.getEventClient();
// create a builder that can record purchase events for the IAP Framework you are using
CustomMonetizationEventBuilder builder = CustomMonetizationEventBuilder.create(eventClient);
// build the monetization event with at minimum the store, product id, quantity, and price information
// The price information can be supplied in either of the following ways:
// - The price as a double (i.e. 1.99) and the currency as a currency code (i.e. "USD"). This method is preferred as it provides more accuracy in the monetization reports
// - The formatted localized price of the item as a string (i.e. "$1.99")
// You may also build with any additional available attributes that the IAP Framework provides such as Transaction ID
// Price and currency
Event purchaseEvent = builder.withStore("Custom Store").withProductId("com.yourgame.sword").withItemPrice(1.99).withCurrency("USD").withQuantity(1).build();
// Formatted Price
purchaseEvent = builder.withStore("Custom Store").withProductId("com.yourgame.sword").withFormattedItemPrice("$1.99").withQuantity(1).build();
// record the monetization event
eventClient.recordEvent(purchaseEvent);
| Modifier and Type | Method and Description |
|---|---|
static CustomMonetizationEventBuilder |
create(EventClient eventClient)
Create a CustomMonetizationEventBuilder with the specified Event client
|
CustomMonetizationEventBuilder |
withCurrency(String currency)
Sets the currency of the item being purchased (Required if formatted localized price is not specified)
|
CustomMonetizationEventBuilder |
withFormattedItemPrice(String formattedItemPrice)
Sets the formatted localized price of the item being purchased (Required if numerical price and currency are not specified)
|
CustomMonetizationEventBuilder |
withItemPrice(double itemPrice)
Sets the numerical price of the item being purchased (Required if formatted localized price is not specified)
|
CustomMonetizationEventBuilder |
withProductId(String productId)
Sets the product identifier field of the item being purchased (Required)
|
CustomMonetizationEventBuilder |
withQuantity(Double quantity)
Sets the quantity of the item being purchased (Required)
|
CustomMonetizationEventBuilder |
withStore(String store)
Sets the store in which the transaction is taking place (Required)
|
CustomMonetizationEventBuilder |
withTransactionId(String transactionId)
The transaction identifier of the purchase (Optional)
|
buildpublic static CustomMonetizationEventBuilder create(EventClient eventClient)
eventClient - The event client to use when creating monetization eventspublic CustomMonetizationEventBuilder withStore(String store)
store - The store in which the transaction is taking placepublic CustomMonetizationEventBuilder withProductId(String productId)
productId - The product id representing the item being purchasedpublic CustomMonetizationEventBuilder withQuantity(Double quantity)
quantity - The quantity of the item being purchasedpublic CustomMonetizationEventBuilder withFormattedItemPrice(String formattedItemPrice)
formattedItemPrice - The formatted localized price of the itempublic CustomMonetizationEventBuilder withItemPrice(double itemPrice)
itemPrice - The numerical price of the itempublic CustomMonetizationEventBuilder withCurrency(String currency)
currency - The currency code of the currency used to purchase this item (i.e. "USD")public CustomMonetizationEventBuilder withTransactionId(String transactionId)
transactionId - The transaction id of the purchaseCopyright © 2010 Amazon Web Services, Inc. All Rights Reserved.