Chord Event Tracking
Getting started
Configuration
8 min
this page documents all configuration options for the @chordcommerce/analytics library initialization options property required default description cdpdomain yes — your chord domain (provided by the chord team) cdpwritekey yes — your chord write key (provided by the chord team) cdp no — reference to an external analytics library if provided, events are also sent to that library formatters yes — functions for transforming your platform's data into the chord tracking plan format metadata yes — event metadata identifying your store and platform consent no — consent adapter "onetrust" , "ketch" , or "shopify" awaitconsent no false if true , delays sending events until consent is given (timeout 1 minute) debug no false validates events against the tracking plan and logs warnings recommended during development enablelogging no true logs errors via console log namespace no "chord" the global namespace where the chord instance is available (e g , window\ chord ) stripnull no true removes properties with null values from events before sending enablewebpixellistener no true receives events from chord's shopify custom web pixel disable if not using the web pixel 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 property required description metadata i18n currency yes iso 4217 currency code, uppercase (e g , usd , gbp , eur ) metadata i18n locale yes locale string (e g , en us , fr fr ) metadata ownership omsid yes uuid assigned by chord (unique per store) metadata ownership storeid yes uuid assigned by chord (unique per store) metadata ownership tenantid yes uuid assigned by chord (unique per organization) metadata platform name yes commerce platform name (e g , shopify , custom ) metadata platform type yes platform type web or pos metadata store domain yes store domain or slug 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 formatter input description formatters objects cart { cart } transforms your cart object into tracking plan format formatters objects checkout { checkout } transforms your checkout object formatters objects lineitem { lineitem } transforms a single line item formatters objects product { product } transforms a single product 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 { / / } }