E-commerce transactions can make great qualifiers for putting visitors into segments. Just knowing that a transaction occurred may sometimes be enough (e.g., for a "Customers" or "High Value Customers" segment).

To track a transaction, simply call the following on your receipt page (or when the transaction is complete):

persosa('transaction', data)

Where data is a JSON object with the following properties:

total

The transaction total.

lineItems

An array of objects, each one representing a line-item that contains the following properties:

  • name
  • sku
  • price
  • quantity

discounts

A value indicating the total value of any and all discounts applied to the transaction.

Transaction example

Let's say a visitor purchases two "Widgets", totally $112.64. The call would look like this:

persosa('transaction', {
  total: 112.64,
  lineItems: [{
    name: 'Widget',
    sku: 'W-001',
    price: 56.32,
    quantity: 2
  }]
});

NOTE: Persosa will not validate that the total is the sum of all products.

Did this answer your question?