Analytics Script

Out of the box analytics platform supporting API clients.

If you use the Smart Size Chart, this functionality already exists in that application, and you do not need to add this to your site!

How It Works

Bold Metrics will identify several elements on your site and listen for events on those elements. Those include:

  • Users opening your size chart

  • Users opening your Fit Tool (your application that calls the Bold Metrics API)

  • Users that Add to Cart

In addition, Analytics offers the ability to collect the API response. When you call the Bold Metrics API, you can trigger a DOM event with the API response as the payload to send the response to Analytics. Send the API Response.

Integrating Analytics

There are three steps to add Analytics to your site:

Add The Script to the PDP Page

This is the first step to integrating Analytics onto your site. This script tag must be included in the <head> element of your PDP:

<script async type="text/javascript" src="https://d2hicexbdkkc9q.cloudfront.net/ssc.production.js"></script>

Add The Element to the Page

Add the following element anywhere on the page. This element will not show to the user, so any location on your PDP will work.

<div id="boldmetrics-analytics"></div>

Analytics will only load if this element is found. If this element is not found, Analytics will not load.

Call the API with the User ID

In order for Bold Metrics to join your purchase data with the recommendation data, you’ll need to call the API with the user id that is generated by Analytics.

The user id can be found in cookies under the name bm. There you’ll find a UUID hash that needs to populate the anon_id query parameter field when you call the Bold Metrics API. This user id is generated after Analytics loads.

Send the API Response

Once you’ve successfully called the API, you can send the API response to Analytics. Here is sample code to call the DOM event. Analytics has a listener for this DOM event:

function sendProductUpdateEvent() {
    document.dispatchEvent(
        new CustomEvent('bmi-recommendation-sent', {
            bubbles: true,
            detail: {
                api: {...api_dict},
            },
        })
    )
}

Last updated