Developers · SDK
Five methods. Everything you need.
The Headless Builds SDK is deliberately small. Capture touches, stitch orders, and read journeys — all fully typed, with sensible defaults baked in.
hb.collect(req, ctx?)Capture a first-party touch from an incoming request. Returns a response with the identity cookie set on your own domain.
Promise<Response>
hb.attribute(order)Stitch a settled order to the visitor's prior touches and persist fractional credit using the configured model.
Promise<Attribution>
hb.identify(visitorId, traits)Attach known traits — email hash, customer id — to a first-party visitor without exposing PII downstream.
Promise<void>
hb.journey(visitorId)Fetch the full ordered timeline of touches for a visitor, useful for debugging and custom reporting.
Promise<Touch[]>
hb.setModel(modelId)Switch the active attribution model. Historical rows stay reproducible under their original model version.
Promise<void>
import { hb } from '@headlessbuilds/shopify' const attribution = await hb.attribute({ orderId: order.id, revenue: order.current_total_price, model: 'data_driven',}) // attribution.credits → per-channel fractionsconsole.log(attribution.credits)Typed end to end.
Full TypeScript definitions ship with every package, so your editor knows the shape of attribution before you do.