Transaction Object
  • 09 Feb 2024
  • 3 Minutes to read

    Transaction Object


      Article Summary

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

      What are the prerequisites?

      • Insider tag must be implemented.
      • Insider object must be defined before the Insider tag. Otherwise 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 are the things to 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 there is also a page object on the page, 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 their own separate product object.

      Sample Code

      Below is a sample code for the Transaction object.

      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 I monitor if it works correctly?

      Once you deploy your integration, you can test it via different methods.

      Insider Object 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. See more on the Insider Object Integration Wizard.

      Browser Test

      To test the Transaction object on your website:

      1. Make a test purchase on your website to go to the Confirmation page.
      2. Right click on your website to inspect the page.
      3. Go to Developer Console.
      4. Run insider_object or insider_object.transaction to see your object.
      5. Make sure that it follows the criteria stated in the properties.


      Was this article helpful?

      ESC

      Eddy, a super-smart generative AI, opening up ways to have tailored queries and responses