Chord Event Tracking
Getting started
Configuration
8 min
this page documents all configuration options for the @chordcommerce/analytics library initialization options true 165,165,165,166 left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type at least one of cdpdomain / cdpwritekey or cdp must be provided if all three are omitted, no events are sent metadata metadata is included with every event and identifies your store to chord metadata { i18n { currency 'usd', // iso 4217 currency code (uppercase) locale 'en us', // locale string }, ownership { omsid ' ', // uuid assigned by chord storeid ' ', // uuid assigned by chord tenantid ' ', // uuid assigned by chord }, platform { name 'shopify', // your commerce platform name type 'web', // 'web' or 'pos' }, store { domain 'my store', // store slug (for shopify the part before myshopify com) }, } metadata fields true 220,220,221 left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type formatters formatters are functions that transform your platform's data structures into the format expected by the chord tracking plan there are two types object formatters (required) and event formatters (optional) object formatters (required) you must provide formatters for four core data types each formatter receives a props object and returns a plain object matching the chord tracking plan schema true 220,220,221 left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type example formatters { objects { cart ({ cart }) => ({ cart id cart id, products cart lines map(line => ({ product id line merchandise product id, sku line merchandise sku, name line merchandise product title, price parsefloat(line merchandise price amount), quantity line quantity, category line merchandise product producttype, })), }), checkout ({ checkout }) => ({ order id checkout id, revenue parsefloat(checkout subtotalprice amount), total parsefloat(checkout totalprice amount), tax parsefloat(checkout totaltax amount), shipping parsefloat(checkout shippingline? price amount || '0'), currency checkout currencycode, products checkout lineitems map(item => ({ product id item variant product id, sku item variant sku, name item title, price parsefloat(item variant price amount), quantity item quantity, })), }), lineitem ({ lineitem }) => ({ product id lineitem merchandise product id, sku lineitem merchandise sku, name lineitem merchandise product title, price parsefloat(lineitem merchandise price amount), quantity lineitem quantity, }), product ({ product }) => ({ product id product id, sku product variants? \[0]? sku, name product title, price parsefloat(product pricerange minvariantprice amount), category product producttype, brand product vendor, url `/products/${product handle}`, image url product featuredimage? url, }), }, } event formatters (optional) event formatters run after chord constructs the event from object formatters, allowing you to transform or enrich specific events before they are sent to chord this is useful when you need to add custom properties or override default behavior for specific events typescript support the library accepts a generic type parameter for type safe formatter inputs interface objecttypes { cart shopifycart checkout shopifycheckout lineitem shopifylineitem product shopifyproduct } const chord = new chordanalytics\<objecttypes>(options) individual formatter types are also available import type { cartformatter, productformatter } from '@chordcommerce/analytics' const cartformatter cartformatter\<shopifycart> = ({ cart }) => { // `cart` is typed as shopifycart return { / / } }