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)
import com.contentsquare.api.model.Transaction;import com.contentsquare.api.contract.Currency;
Transaction transaction = new 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"Currency.USD.integerCode // 840
import com.contentsquare.api.contract.Currency;
Currency currency = Currency.USD;Currency currencyFromString = Currency.fromString("USD");Currency currencyFromInteger = Currency.fromInteger(840);
// string or integer ISO code can also be retrieved from the enum valueCurrency.USD.stringCode // "USD"Currency.USD.integerCode // 840