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

Function: trackOrderConfirmed (Order, Optional[Strict])

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.

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 formerly the product array in our Legacy Enhanced Analytics. If you keep the existing parameters to include the product array, we'll simply ignore the value and treat it as null.

📘

Passing the true value

The true value in the third parameter is also required


Objects

Order

ParameterData typeDescription
order requiredObjectContains details about the customer’s order

The order object should contain the following details:

ParameterData typeDescription
currency requiredstringThree-letter ISO currency code, in uppercase.

Possible values:

- USD
- CAD
orderID requiredstringUnique identifier representing the order/transaction in your system
paymentMethod requiredstringDescription of payment method used

(ex. “Visa”, “Mastercard”, “Gift Card”,"Affirm")
total
required
integerThe total value of the transaction, including tax and shipping. The value must be non-negative and represented as cents instead of dollars.