JavaScript API
The snippet defines window.qm. Every command works in two forms:
- The call form,
qm("command", …args), works at any time, also before the script has loaded. Use it. - The method form,
qm.command(…)orqm.commerce.method(…), works only after the script has loaded.
Types for all of these are in qm.d.ts.
| Command | Arguments | What it does |
|---|---|---|
init |
{ key, commerce?, cookieDomain?, debug?, endpoint? } |
Starts the script. Once per page; the snippet does it. See options. |
consent |
{ analytics?, replay? } |
Passes on the visitor’s choice. Every page load. See Consent. |
page |
{ type } |
Sets this page’s type. |
track |
name, props? |
A custom event. Both modes. |
identify |
customerId |
Links the session to a customer, as a hash. See Custom events and customers. |
qm("init", { key: "pk_live_…" });qm("consent", { analytics: true, replay: true });qm("page", { type: "thank_you" });qm("track", "size_guide_opened", { category: "shoes" });qm("identify", "customer-1042");Commerce
Section titled “Commerce”Sent only in manual mode. In auto mode they are ignored.
| Command | Arguments |
|---|---|
commerce.productViewed |
product |
commerce.cartAdded |
product, quantity? |
commerce.cartRemoved |
product, quantity? |
commerce.cartViewed |
cart |
commerce.checkoutStarted |
cart |
commerce.shippingMethodSelected |
method |
commerce.paymentMethodSelected |
method |
commerce.paymentRedirected |
method, provider |
commerce.paymentReturned |
method, provider, "success" | "failure" | "unknown" |
commerce.couponApplied |
code, accepted |
commerce.purchase |
order |
commerce.searchPerformed |
term, resultCount? |
commerce.itemListViewed |
list, itemCount? |
commerce.itemSelected |
product, list?, index? |
commerce.wishlistAdded |
product |
commerce.promotionViewed |
promotion |
commerce.promotionSelected |
promotion |
commerce.signedUp |
method? |
commerce.loggedIn |
method? |
The shapes of product, cart, order, list and promotion are in Manual mode.
qm.versionis the loaded script’s version, such as"0.1.0". It exists only after the script has loaded.- An unknown command, or arguments of the wrong shape, are ignored. With
debug: true, the script logs why. - No command ever throws.
HTML attributes
Section titled “HTML attributes”| Attribute | Effect |
|---|---|
data-qm-mask |
Text inside is masked in replays. |
data-qm-block |
The element is not recorded; the replay shows an empty box. |
| URL | What |
|---|---|
https://ingest-prod.quomerce.com/sdk/v0/qm.js |
The script. v0 follows every compatible release. |
https://ingest-prod.quomerce.com/sdk/v0/qm.d.ts |
The TypeScript types. |
https://ingest-prod.quomerce.com |
Where events and replays are sent. |
https://app.quomerce.com |
The Quomerce app. |