Purchase Script
Application to send Bold Metrics your Purchase data from the browser.
The Purchase API is designed to collect purchase data as it relates to the usage of the Smart Size Chart & Virtual Sizer API. We log all purchases sent and are able to match them to recommendations to provide additional analysis.
Implementation
Shopify Sites
Checkout Extensibility Pixel
Open the Customer Events panel in your Shopify admin. It can be found at this link: https://admin.shopify.com/settings/customer_events
From the Customer Events panel, click the button in the upper right corner of the page which says 'Add Custom Pixel'.
Name the custom pixel: 'Bold Metrics - Purchases'. This will take you to a screen where you can paste in a custom pixel.
Copy and paste the below code in the code block box and then click
Save
in the upper right corner of the screen. Then, click theConnect
button to activate the pixel.
Note: you must fill the
client_id
field with the value provided to you by the Bold Metrics engineering support team, i.e. replace the text that says "YOUR CLIENT ID GOES HERE" wioth your actual client id.
In the options for the pixel, there may be options for Customer Privacy. Under the 'Permission' option, select 'Not Required' (we are not collecting customer data for marketing, analytics or preferences purposes), and under the 'Data Sale' option, select 'Data collected does not qualify as data sale'.
Non-Shopify Sites
The first step is to add the script below to your order confirmation page. Note: It is very important that we receive all of the data listed below.
This exposes the window.bmiWriteTransaction
function which can be used to pass transaction data to. Please see below, all fields listed below are REQUIRED:
This function returns a promise and is thenable, which allows the client to get the API response to confirm data has been written. See below for additional information on the Purchase API payload.
This script will also collect a user_id in cookies that the either the analytics script or the SSC script sets .
Send your Bold Metrics representative an order confirmation URL for internal testing purposes.
Purchase Templates
The below sheets contain the data Bold Metrics requires to validate that the above script was implemented correctly. This allows us to do a 'quality check' to verify that we're getting purchase data correctly, so we can provide reporting.
Once you go live with either the API or Smart Size Chart, we'll request 3 days of purchase data to validate that we have parity between your purchase data and our newly collected data coming from the purchase script above.
Bold Metrics will validate this comparison and will report that we are getting the appropriate purchase data.
Logging & Monitoring
It's a recommended best practice to both log and monitor this script. Once data is posted to window.bmiWriteTransaction
, Bold Metrics will receive these records if the call was successful, however, we will not receive this data if the call was not successful.
Adding a monitoring utility will help both teams identify purchases that may not have successfully been posted to Bold Metrics.
Troubleshooting
For most issues you may encounter, there is likely an associated error in the console. To open the console in your browser, press Cmd + Alt + i (Firefox & Chrome). If there is an error, the promise will return an error message.
Some common issues are around sending the proper data contract. See the above example for the acceptable data contract. We validate for all of the above fields, so please submit requests as seen above.
In addition, we also validate for a cookie with the name bm
and that it has a value. This is automatically set by the Smart Size Chart application if it’s used on your site, and without it, you may need to manually set this cookie during testing to receive a 200 from the API. In order for the Smart Size Chart to set a cookie value, you’ll need to visit the application for the cookie to be set.
Last updated