Docs Reference
View as MarkdownJavaScript API
The snippet creates the tracker as window.clerion once the page has loaded. Everything below is optional: pageviews, clicks, scroll, forms, speed, errors and rage clicks are tracked without any code.
Code that may run before the tracker exists should guard the call:
window.clerion?.trackEvent("signup");
trackEvent
window.clerion.trackEvent(name, details);
Records a custom event. Every name Clerion does not use itself appears on the Custom events page the first time it arrives. details is optional; three keys have meaning in the dashboard:
| Key | What it does |
|---|---|
value | Summed per event, and read by Revenue by source. orderValue and revenue are accepted as aliases. A number or a numeric string. |
currency | Shown next to the value. |
path | Overrides the page the event is attributed to. |
window.clerion.trackEvent("purchase", { value: 49, currency: "USD", plan: "starter" });
The full guide, with the HTML attribute alternative and the reserved names, is Custom events.
Attribute an event to a different page than the one it fired on, for example a modal that lives on every page:
window.clerion.trackEvent("demo_request", { path: "/book-a-demo" });
For TypeScript, declare the global once; the declaration is in Custom events.
trackPageView
window.clerion.trackPageView(path, details);
Records a pageview by hand. Rarely needed: the first pageview and every client-side route change are counted automatically. path defaults to the current page.
Commerce helpers
These record the built-in commerce events that feed the ecommerce funnel, product view to cart to checkout.
| Method | Records |
|---|---|
trackProductView(productId, productName, { category, price }) | product_view |
trackAddToCart(productId, productName, quantity, price, size) | add_to_cart. quantity defaults to 1. |
trackRemoveFromCart(productId, productName, quantity, price) | remove_from_cart |
trackCheckoutStart(products, orderValue) | checkout_start |
trackSearch(query, resultsCount) | search |
trackCategoryClick(categoryName) | category_click |
trackBannerClick(bannerIndex, details) | banner_click |
trackWishlistAdd(productId, productName, details) | wishlist_add |
trackWishlistRemove(productId, productName) | wishlist_remove |
trackFilterApply(filterType, filterValue, appliedFilters) | filter_apply |
trackSortChange(field, order) | sort_change. order defaults to asc. |
A completed purchase is not a built-in name. Send it with trackEvent and a value, so it counts as revenue.
Consent
window.clerion.setConsentStatus(true);
Records the visitor's choice, as Clerion's optional consent banner does. With consent given, Clerion keeps a visitor id for up to a year, which lets Revenue by source follow a visitor across visits. setConsentStatus(false) removes it, and that browser is not tracked on later visits. Without a choice, Clerion runs cookie-free and counts each visit on its own.
Limits on details
| Limit | Value |
|---|---|
| Size | 5 KB per event. Larger payloads are rejected and the event is not stored. |
| Strings | Truncated at 500 characters. |
| Arrays | 50 items. |
| Nesting | 5 levels. |
| Keys | 100 characters. |
Do not put personal data in event details. A plan name is fine; an email address is not.