Clear History

Track Transactions

Transaction events are used to track the successful completion of a purchase/transaction on your e-commerce store.


Tracking transaction completion

In this section, we will showcase how to track a completed transaction.

TransactionEvent

To track a completed transaction you can use the TransactionEvent with the following attributes:

AddToCartEvent(transaction: TransactionEntity, products: [ProductEntity]?)
  • Where transaction is a transaction object.
  • Where products is an array with the product/s in the transaction.

Example usage:

let transaction = TransactionEntity(
  transactionId: "id-123", 
  revenue: 230, 
  currency: "GBP", 
  paymentMethod: "debit", 
  totalQuantity: 2,
  tax: 20,
  shipping: 10
)
let product = ProductEntity(
  id: "productId", 
  category: "clothes/shirts", 
  currency: "GBP", 
  price: 100
)

tracker.track(TransactionEvent(transaction: transaction, products: [product]))

TransactionEvent

To track a completed transaction you can use the TransactionEvent with the following attributes:

AddToCartEvent(transaction: TransactionEntity, products: List<ProductEntity>?)
  • Where transaction is a transaction object.
  • Where products is an array with the product/s in the transaction.

Example usage:

val transaction = TransactionEntity(
  transactionId = "id-123", 
  revenue = 230, 
  currency = "GBP", 
  paymentMethod = "debit", 
  totalQuantity = 2,
  tax = 20,
  shipping = 10
)
val product = ProductEntity(
  id = "productId", 
  category = "clothes/shirts", 
  currency = "GBP", 
  price = 100
)

tracker.track(TransactionEvent(transaction: transaction, products: listOf(product)))

TransactionEvent

To track a completed transaction you can use the TransactionEvent with the following attributes:

AddToCartEvent(transaction: TransactionEntity, products: List<ProductEntity>?)
  • Where transaction is a transaction object.
  • Where products is an array with the product/s in the transaction.

Example usage:

TransactionEntity transaction = TransactionEntity(
  "id-123", // transactionId
  230, // revenue
  "GBP", // currency
  "debit", // paymentMethod
  2, // totalQuantity
  20, // tax
  10 // shipping
);
ProductEntity product = new ProductEntity(
  "productId", // id
  "clothes/shirts", // category
  "GBP", // currency
  100 // price
);

tracker.track(TransactionEvent(transaction, Arrays.asList(product)))

Where ProductEntity can have the following attributes:

attributetypedescriptionrequired
idstringSKU or product ID.
currencystringCurrency in which the product is being priced (ISO 4217).
pricenumberPrice of the product at the current time.
namestringName or title of the product.
categorystringCategory the product belongs to. Use a consistent separator to express multiple levels. E.g. Woman/Shoes/Sneakers. The number of levels is defined by the user.
listPricenumberRecommended or list price of a product.
quantitynumberQuantity of the product taking part in the action. Used for Cart events.
sizestringSize of the product. E.g. XL, XS, M.
variantstringVariant of the product. E.g. Red, Heavy, Leather.
brandstringBrand of the product.
inventoryStatusstringInventory status of the product. E.g. in stock, out of stock, preorder, backorder.
positionnumberPosition the product was presented in a list of products. Used in Product List events.
creativeIdstringIdentifier/Name/Url for the creative presented on a list or product view.

Where TransactionEntity can have the following attributes:

attributetypedescriptionrequired
transactionIdstringThe ID of the transaction
currencystringThe currency used for the transaction (ISO 4217).
revenuenumberThe revenue of the transaction.
paymentMethodstringThe payment method used for the transaction.
totalQuantitynumberTotal quantity of items in the transaction.
taxnumberTotal amount of tax on the transaction.
shippingnumberTotal cost of shipping on the transaction.
discountCodestringDiscount code used.
discountAmountnumberDiscount amount taken off.
creditOrderbooleanWhether the transaction is a credit order or not.