## Overview
Our `Affirm.js
` library now includes Confirmation Page Analytics. Confirmation Page Analytics offers insight into how customers interact with your site on the confirmation page. When a customer completes their purchase, you can send their order and product information to Affirm for tracking A/B testing, which will help you optimize your site and comprehensively measure the eCommerce lifecycle. You can send this information by adding the Confirmation Page function to your order confirmation page. Additionally, you can enable our [Enhanced analytics](🔗) functions to measure customer interactions with your site across their entire shopping experience.
## 1. Add Affirm.js
Before adding Enhanced Analytics function, you need to add the Affirm.js embed code to your global page template or in the global header if you haven't already done so:
## 2. Add Confirmation Page Function
The `trackOrderConfirmed
` event triggers when a customer completes their purchase. It measures the sale of one or more products. This function should be populated with order and products argument before adding it to the order confirmation page. All the values in the order and product arguments must be based on the order that was placed. We only require orderId, total, productId, and quantity for A/B testing.
**Parameters:**
`
order
` _object_ - The order`
products
` _array_ - Products sold to the customer
Returns:
null
**Example**
## Data types
**Order object**
The `order
` object defines the customer's order when they begin the checkout process. It also includes transaction information when the customer completes checkout.
Parameter | Column Title | Description |
**storeName** <span style="color:red">required</span> | _string_ Maximum 500 characters. | Your store name. |
checkoutId _optional_ | _string_ Maximum 500 characters. | Your internal unique identifier representing the checkout if it’s distinct from the order ID. If they are the same, only orderID is needed. |
**coupon** _optional_ | _string_ Maximum 500 characters. | The coupon code applied to the order (e.g., SUMMER2018). |
**currency ** _optional_ | _string_ | USD |
**discount ** _optional_ | _integer_ | The total discount applied to the order, stated in USD cents (e.g., $100 = 10000). |
**orderID ** <span style="color:red">required</span> | _string_ Maximum 500 characters. | Your internal unique identifier representing the order. |
**paymentMethod ** <span style="color:red">required</span> | _string_ Maximum 150 characters. | The payment method chosen by the customer (e.g., Visa) |
**revenue** _optional_ | _integer_ | The shipping cost associated with the order. |
**shipping** _optional_ | _integer_ | The shipping cost associated with the order. |
**shippingMethod** _optional_ | _string_ Maximum 150 characters. | The shipping method chosen by the customer (e.g., Fedex). |
**tax** _optional_ | _integer_ | The total tax amount associated with the order, stated in USD cents (e.g., $100 = 10000). |
**total** _optional_ | _integer_ | The total amount of the transaction including tax and shipping, stated in USD cents (e.g., $100 = 10000). If not sent, the total amount will be calculated using the product quantity and price fields of each product object passed. |
**Product object**
The `product
` object defines the product offered by the merchant.
Parameter | Column Title | Description |
**brand** _optional_ | _string_ Maximum 500 characters. | The brand of the product (e.g., Affirm). |
**category** _optional_ | _string_ Maximum 500 characters. | The product category. |
**coupon** _optional_ | _string_ Maximum 500 characters. | Any coupon code applied to this particular product. |
**name** _optional_ | _string_ Maximum 500 characters. | The full name of the product (e.g., Affirm T-Shirt). |
**price** _optional_ | _integer_ | The price of the purchased product, stated in USD cents (e.g., $100 = 10000). |
**productID ** <span style="color:red">required</span> | _string_ Maximum 500 characters. | Your unique internal identifier representing the product, such as the SKU or an internal database identifier. |
**quantity** _optional_ | _integer_ | The quantity of the purchased product. |
**variant** _optional_ | _string_ Maximum 500 characters. | The variant of the product (e.g. black). |
**currency** _optional_ | _string_ | A [currency code](🔗) associated with this product (USD) |