Skip to main content

Tracking Events

Tracking Custom In-App Actions

tip

The steps below provide instructions for tracking in-game events. FIRST_RUN, OPEN and TIME_SPENT events are tracked automatically.

To track in-game actions add the following line:

Wappier.getInstance().trackAction("YOUR_CUSTOM_EVENT_NAME", data);    

YOUR_CUSTOM_EVENT_NAME can have any custom value including the following special characters:

*0-9, A-Z, a-z, # $ % = @ ! { } ( ) [ ] < > ` ~ & ? . : ; _ | ^ + –*

You can pass any Object in the second parameter of trackAction (e.g., List, HashMap<String,Any>, etc.).These actions are directly correlated with the gameplay style of each game and they are the main source of points for the user. Here you may find some common examples of tracked actions:

Event NameOccurenceTracked whenData
LEVEL_COMPLETEDRepetitiveThe user completes a level
or stage in the game
levelNumber:3
BATTLE_WONRepetitiveWin a match versus A.I.
HERO_LVL_UPRepetitiveThe hero leveled up.
Extra Data: the exact level
number and the number of win
in pvp battles
characterLevel:7,
pvpWins:35

Tracking Purchase Events

The PURCHASE event is sent every time a user purchases one of your application’s in-app items.

In order to track in-app purchases performed in your game, add the following line:

Wappier.getInstance().trackPurchase(
revenue,
"currencyCode",
"googleOrderId",
"productId",
"purchaseToken",
"purchaseType",
data
);

The following code snippet suggests a way to track a purchase event:

// Callback for when a purchase is finished
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
if (purchase.getSku().equals(..SKU id..)) {
HashMap<String, String> data = new HashMap<>();
data.put("key1", "value1");
data.put("key2", "value2");

Wappier.getInstance().trackPurchase(
1.80,
"EUR",
purchase.getOrderId(),
purchase.getSku(),
purchase.getToken(),
purchase.getType(),
data
);
}
};

Alternatively, if the current user is in a pricing target group and the product id argument is a proxy SKU, then you can instead use this function to report to wappier’s SDK the related original SKU:

Wappier.getInstance().trackPurchase(
revenue,
"currencyCode",
"googleOrderId",
"productId",
"purchaseToken",
"purchaseType",
"originalSku",
data
);

An optional map of extra data can be passed in the above methods in argument data.

Mandatory Fields

ValueTypeDescriptionExample
revenueDoubleTotal numeric amount
for the purchase
19.99
currencyCodeStringThe local currency code
of the transaction
USD
googleOrderIdStringThe GPA-formatted order
ID of the transaction
GPA-1234.1234.1234.12345
productIdStringThe product identifier,
which is defined on your Google
Developer Console
com.xxxx.yyyy.gems
purchaseTokenStringA token that uniquely
identifies a purchase
for a given item and user pair
This alphanumeric string
is 150-200 characters long
purchaseTypeStringA virtual good type
that allows us to further
differentiate the types
of items that users buy
from your game
Gems

Tracking Store Impression

The wappier optimization SDK provides custom methods to track the behavior of users in an in-game store.

When the user enters the app’s store view, you can call trackStoreImpression by providing the store name and a list of your products:

final List<StoreItem> storeItemList = new ArrayList<>();

for (SkuDetails skuDetails : list) {
StoreItem storeItem = new StoreItem.Builder()
.withSku(skuDetails.getSku())
.withCurrency(skuDetails.getPriceCurrencyCode())
.withPrice(10)
.withInitialPrice((double) skuDetails.getPriceAmountMicros() / 1000000)
.withPromo("Promo")
.build();
storeItemList.add(storeItem);
}

Wappier.getInstance().trackStoreImpression("Gem_Store", storeItemList);

StoreItem is a WappierSDK builder that keeps the product's info from Google/Apple API.

 StoreItem storeItem = new StoreItem.Builder()
.withSku("PRODUCT_SKU")
.withCurrency("PRODUCT_CURRENCY"))
.withPrice(10)
.withInitialPrice(20)
.withPromo("MOST_POPULAR")
.build();

XNStoreItem is a WappierSDK class to describe Store Items:

ValueDescription
skuCurrent sku (already provided by Google Purchace API)
currencyThe currency of your product
priceThe actual price paid
initialPriceThe initial pre-discount price in Micros
PromoTextAn optional promo text

When the user exits from an in-game store you can call trackStoreExit by providing the store name:

Wappier.getInstance().trackStoreExit("store");

You are able to track the attempts of a user to purchase an in-app item by providing the current StoreItem:

StoreItem storeItem = new StoreItem.Builder()
.withSku("PRODUCT_SKU")
.withCurrency("PRODUCT_CURRENCY"))
.withPrice(10)
.withInitialPrice(20)
.withPromo("MOST_POPULAR")
.build();

Wappier.getInstance().trackPurchaseIntent(storeItem);

Tracking Currency Balance

The wappier Optimization SDK provides a currency balance system to track the changes in a user’s economy:

Wappier.getInstance().trackBalance("Gem", 10, 5000, "CHEST_OF_GOLD");
ValueDescription
balanceTypeThe currency identifier
(e.g., DIAMONDS, GOLD, etc.)
amountThe amount of the balance change
(can be positive or negative)
currentBalanceThe current total balance after
the amount of change has been applied
reasonThe reason for which the
amount of currency was modified