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.api.model.Transactionimport com.contentsquare.api.contract.Currency
val transaction = Transaction(430.99f, Currency.EUR, "my_id")CSQ.trackTransaction(transaction)Currency
Section titled CurrencyThe Currency enum provides a list of all supported currencies, conforming to the ISO 4217 ↗ standard.
import com.contentsquare.api.contract.Currency
val currency = Currency.USDval currencyFromString = Currency.fromString("USD")val currencyFromInteger = Currency.fromInteger(840)
// string or integer ISO code can also be retrieved from the enum valueCurrency.USD.stringCode // "USD"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).