Track transactions
To associate a user’s session with their potential purchases (and corresponding revenue), you must send the transaction via a dedicated API. For each transaction, we send:
- Price (mandatory)
- Currency (mandatory)
- Transaction ID (optional)
import com.contentsquare.android.api.Currencies;import com.contentsquare.android.api.model.Transaction;
// Sends Transactionfloat price = 430.00f;String id = "id";// CurrencyCurrencies currency = Currencies.EUR; // or currency = "USD"
Contentsquare.send(Transaction.builder(price, currency).id(id).build());import com.contentsquare.android.api.Currenciesimport com.contentsquare.android.api.model.Transaction
// Sends Transactionval price = 430.00fval id = "id"// Currencyval currency = Currencies.EUR // or currency = "USD"
Contentsquare.send(Transaction.builder(price, currency).id(id).build())Currency
Section titled CurrencyThe currency is conforming to the ISO 4217 ↗ standard. The currency can be passed either as “alphanumeric code” or “numeric code”.
If the currency passed doesn’t match the supported currencies, the SDK will send a currency value of -1. It will be processed as the default currency of the project.
Float precision
Section titled Float precisionThe Transaction API uses a Float to represent the transaction value, which means very large numbers may be rounded when stored or serialized.
For example, 1234567890f becomes 1234567936f.
This behavior is normal for floating-point values and does not affect regular currency amounts (0.99, 430.00, 100000.00).