Transaction Object

Prev Next

The Transaction Object includes information about the completed purchase. It should be implemented only on the Confirmation (Success) page.

This guide explains the following:


What are the prerequisites?

  • Insider tag must be implemented.
  • Insider object must be defined before the Insider tag. Otherwise, the Insider tag cannot read any information from the Insider object.

What are the properties?

The Transaction object has the following properties.

KeyPropertyTypeDefinitionRequired
order_idOrder IDStringOrder ID of the transactionYes
currencyCurrencyStringCurrency used for product pricing, in ISO 4217 format (e.g. USD)Yes
totalTotal PriceFloatTotal price of the transaction, including any shipping fees or taxesYes
line_itemsPurchased itemsArrayAn array containing the purchased itemsYes
productProductObjectProduct objectYes
idProduct IDStringUnique product ID, should match ID on product pageYes
nameProduct NameStringName of the productYes
taxonomyBreadcrumbArrayCategory tree of the productYes
currencyCurrencyStringCurrency used for product pricing, in ISO 4217 format (e.g. USD)Yes
unit_priceProduct price without any discount(s)FloatPrice of the product without any discount(s)Yes
unit_sale_priceUnit priceFloatUnit price of the productYes
urlProduct page linkStringURL address of the productYes
stockStock information of the productNumberNumber of products left in stockNo
colorProduct colorStringColor of the product (selected by user)No
sizeProduct sizeStringSize of the product (selected by user)No
product_image_urlProduct image linkStringURL address of the product imageYes
quantityQuantityNumberNumber of productsYes
subtotalTotalFloatTotal sum of the unit sale prices of the productsYes
shipping_costShipping costFloatShipping cost of the itemsNo
deliveryDelivery addressObjectDelivery address objectNo
countryDelivery countryStringCountry information in ISO 3166-1 alpha-2 formatNo
cityDelivery cityStringCity of the addressNo
districtDelivery districtStringDistrict of the addressNo
bank_nameBank nameStringName of the bank used for the paymentNo
customCustomObjectCustom object that includes custom properties to be collected to Insider database as custom event parametersNo

What should you keep in mind?

When integrating the object, the following factors should be considered.

Your title goes here
The following visuals from the developer console are sample visuals. In your case, the values might vary depending on the key.
  • The page should return Confirmation as the type after running window.insider_object.page.type on the browser console.
  • window.insider_object.transaction should return the correct purchased products.
  • window.insider_object.transaction.total should return the correct total order amount.
  • window.insider_object.transaction.currency should return the correct currency.
  • If the page also has a page object, the transaction object and the page object should both be nested on the same level under the insider_object.
  • If there are multiple purchased products, each product should have its own separate product object.

Sample code

Below is a sample code for the Transaction object with two purchased products.

window.insider_object = window.insider_object || {};
window.insider_object.transaction = {
    "order_id": "xyz123456",
    "currency": "USD",
    "total": 200.4,
    "shipping_cost": 9.9,
    "delivery": {
        "country": "UK",
        "city": "London",
        "district": "Kensington"
    },
    "bank_name": "BANK",
    "line_items": [
        {
            "product": {
                "id": "N1234",
                "name": "Sleep Mask",
                "taxonomy": [
                    "Skincare",
                    "Moisturizers",
                    "Night Creams"
                ],
                "currency": "USD",
                "unit_price": 100,
                "unit_sale_price": 95.2,
                "url": "https://www.mywebsite.com/en-us/sleep-mask/n1234/",
                "stock": 150,
                "color": "Blue",
                "size": "S",
                "product_image_url": "https://www.mywebsite.com/product_images/n1234.png/",
                "custom": {
                    "season": "Winter",
                    "delivery_time": "In 5 days"
                }
            },
            "quantity": 1,
            "subtotal": 95.2
        },
        {
            "product": {
                "id": "M1234",
                "name": "Sleep Mask",
                "taxonomy": [
                    "Skincare",
                    "Moisturizers",
                    "Night Creams"
                ],
                "currency": "USD",
                "unit_price": 110,
                "unit_sale_price": 105.2,
                "url": "https://www.mywebsite.com/en-us/sleep-mask/m1234/",
                "stock": 140,
                "color": "Blue",
                "size": "S",
                "product_image_url": "https://www.mywebsite.com/product_images/m1234.png/",
                "custom": {
                    "season": "Summer",
                    "delivery_time": "In 5 days"
                }
            },
            "quantity": 1,
            "subtotal": 105.2
        }
    ]
}

In addition to the properties defined in the table above, you can add custom properties to any object. Such properties should be added under the custom object, as in the example above.

Your title goes here
The key-value pairs under the custom object are attributed as custom event parameters to the Purchase event.
Your title goes here
The value type of any key under the custom object varies depending on the key. Make sure to add the values in the data type that fits the best.

How can you monitor if the integration works correctly?

Once you deploy your integration, you can test it via the Website Integration Wizard. This wizard helps you complete your integration and test it afterwards. If you have already implemented the integration, you can use the wizard only to test it as well.