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 formally 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.


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”)
total
required
integerThe 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

ParameterData typeDescription
Strict
optional
booleanTrue/False flag for ensuring the currency, orderID, paymentMethod, and total are sent in the Order object. This value must be true in order to use the Enhanced Analytics implementation.

Did this page help you?