Enhanced analytics
Learn more about Affirm’s marketing measurement tools and the data you can provide to get more value from your partnership with Affirm over time.
Overview
The Enhanced Analytics plugin for the Affirm.js
library is a simple, easy-to-use tool allowing deeper integration with Affirm to measure customer interactions across your site. With Enhanced Analytics enabled, Affirm is better able to help you understand your customers’ financial preferences and tailor their shopping experiences accordingly.
How it works
As a user navigates between web pages, Affirm.js records information about their session. This includes discrete events for tracking product impressions, viewing product details, adding to or removing from the shopping cart, initiating the checkout process, and completing a purchase.
The most important signal that Affirm can use to help you increase the value of your integration comes from order confirmation data; as a result, sending this event type is the only requirement in integrating Enhanced Analytics.
Sending confirmation events
The trackOrderConfirmed
function accepts basic data about each confirmed customer order from your confirmation page and sends the details to Affirm’s improved data pipeline for use in our analytics tools.
Implementation
1. Add the Affirm.js
SDK to the confirmation page (Affirm.js may already be loaded on all site pages for some merchants)
2. Upon load of the confirmation page, prepare the following data to be passed to the trackOrderConfirmed
function.
Order
object - JSON object containing the following details:
3. Call the trackOrderConfirmed
function and provide the previously gathered data as the parameters. We included an example call below.
affirm.analytics.trackOrderConfirmed({
"currency": "USD",
"orderId": "AA-87654",
"paymentMethod": "Affirm",
"total": 23595
}, null, true);
Passing the null value
You can pass
null
in second required parameter. This was formally theproduct
array in our Legacy Enhanced Analytics. If you keep the existing parameters to include theproduct
array, we'll simply ignore the value and treat it asnull
.
Objects
Order
The order object should contain the following details:
Parameter | Data type | Description |
---|---|---|
string | Three-letter ISO currency code, in uppercase. Possible values:
| |
string | Unique identifier representing the order/transaction in your system | |
string | Description of payment method used (ex. “Visa”, “Mastercard”, “Gift Card”) | |
integer | The total value of the transaction, including tax and shipping. If not sent, this value will be automatically calculated using the product quantity and price fields of all products in the same hit. The value must be non-negative and represented as cents instead of dollars. |
Strict
Parameter | Data type | Description |
---|---|---|
| boolean | True/False flag for ensuring the |
Updated about 1 year ago