JS tracker API
The standard snippet (data-site) already captures pageviews, clicks, Web Vitals, forms, media, heatmaps and automatic e-commerce and identity detection for 25+ shop systems — without a single line of code. The global JavaScript API window.xictraq is for everything beyond that: custom events, manual e-commerce tracking in custom and headless front-ends, user identification, A/B testing and the consent gate. This page documents every method with signature, example and return value.
# Prerequisite & guard
The JS API is available as soon as the regular tracker snippet is embedded — you do not need a second script. For the standard cases (reach, forms, media, heatmaps, Web Vitals and e-commerce/identity for 25+ shop systems) you do not have to write any code at all; the API is meant purely for manual and additional cases.
<script defer src="https://api.xictraq.com/t.js"
data-site="YOUR_SITE_ID"></script> <script defer src="/t.js" data-site="…" data-api="/a">. window.xictraq, every method documented here and their return values stay identical — only the beacon target moves to your domain. Your own calls such as xictraq.event() or xictraq.revenue() then also go through /a/ on your domain. The tested nginx block for /t.js, /a/ and, with session recording, /rx.js, with the HSTS of api.xictraq.com hidden, X-Forwarded-For overwritten and a 20 MB request size for recordings, is in Getting started.When window.xictraq is available — always call defensively
The tracker loads with script defer, so window.xictraq only exists after the snippet has executed. There is no pre-buffer: calls made before it loads are dropped. Therefore call the API defensively — only when window.xictraq exists (or after the load event).
<script>
// window.xictraq only exists once the tracker has loaded.
if (window.xictraq) {
xictraq.event('newsletter_signup', { plan: 'pro' });
}
</script># Custom events
Send custom events (event)
xictraq.event(name, props?) reports any event. name is a string, props an optional object with freely chosen properties. Use it to capture interactions no standard feature covers — e.g. newsletter sign-ups, downloads or CTA clicks.
// Simple event without properties
xictraq.event('newsletter_signup');
// Event with properties (any object)
xictraq.event('newsletter_signup', { plan: 'pro', source: 'footer' });
// More examples
xictraq.event('download', { file: 'price-list.pdf' });
xictraq.event('video_cta_click', { position: 'hero' });# User identification
Link the session to a customer/shop ID (identify)
xictraq.identify(userId, traits?) links the initially pseudonymous session (daily identifier) to a customer or shop ID. The customer number and traits are personal data; only pass what you need for the analysis. userId is your internal ID or customer number, traits an optional object with attributes such as type or group. Returning customers then appear across days as identified users in the dashboard.
// ID only
xictraq.identify('cust_10492');
// With additional traits (no email addresses)
xictraq.identify('cust_10492', { type: 'b2b', group: 'returning' });<!-- 1) Global variable -->
<script>window.xictraqUser = { id: 'cust_10492', type: 'b2b' };</script>
<!-- 2) Meta tag in <head> -->
<meta name="xictraq:user-id" content="cust_10492">
<!-- 3) Attribute on any element -->
<body data-user-id="cust_10492"> # Manual e-commerce
Order / revenue (revenue)
xictraq.revenue(amount, currency, orderId, extras?) reports a completed purchase. amount is the gross amount as a number, currency an ISO currency code, orderId your order number. extras is an optional object with tax, shipping and coupon.
xictraq.revenue(129.90, 'EUR', 'ORDER-2026-8841', {
tax: 20.75,
shipping: 4.95,
coupon: 'WELCOME10'
});Product view (product)
xictraq.product('view', props) reports that a visitor viewed a product. props holds the fields id, name, price and category.
xictraq.product('view', {
id: 'SKU-4471',
name: 'Running Shoe Pro',
price: 119.00,
category: 'Shoes/Running'
});Cart (cart)
xictraq.cart('add' or 'remove', props) reports a cart change. The first parameter is the action, props holds id, name, price and quantity.
// Add to cart
xictraq.cart('add', { id: 'SKU-4471', name: 'Running Shoe Pro', price: 119.00, quantity: 1 });
// Remove from cart
xictraq.cart('remove', { id: 'SKU-4471', name: 'Running Shoe Pro', price: 119.00, quantity: 1 });Checkout step (checkout)
xictraq.checkout(step, meta?) marks a step in the checkout funnel. step is a number or a name, meta an optional object with additional info about the step.
xictraq.checkout(1, { step_name: 'Address' });
xictraq.checkout(2, { step_name: 'Shipping' });
xictraq.checkout('payment');Refund (refund)
xictraq.refund(orderId, amount, currency) reports a refund for a previous order. All three parameters are required: the original order number, the refunded amount and the currency code.
xictraq.refund('ORDER-2026-8841', 129.90, 'EUR');Failed payment (paymentFailed)
xictraq.paymentFailed(orderId, amount, currency, extras) reports a payment that the payment provider declined or that was cancelled there. Only the shop knows about it, so there is no automatic detection. The payment method goes into extras.payment_method; if it is missing, the tracker reads it from the page as it does for a purchase. The payment and shipping report turns this into the share of failed attempts per payment method and how many sessions still bought afterwards.
xictraq.paymentFailed('ORDER-2026-8842', 89.00, 'EUR', { payment_method: 'Credit card' });# A/B testing
Assign a variant (experiment)
xictraq.experiment(name) assigns an A/B variant to the visitor and returns a Promise that resolves with the variant (e.g. 'A' or 'B'). The assignment hangs on the cookieless session key made of IP address and date: within a day the same visitor sees the same variant, on the next day or after an IP address change they can be assigned anew. If no experiment of that name is running, the Promise resolves with null.
xictraq.experiment('pricing_headline').then(function (variant) {
if (variant === 'B') {
document.querySelector('#headline').textContent = 'New: 30 days free';
}
});Report a conversion (convert)
xictraq.convert(name) reports that the visitor reached the experiment goal — e.g. a purchase or a sign-up. From this XICTRAQ computes conversion rate, uplift and statistical significance per variant.
// e.g. after a CTA click or a completed purchase
xictraq.convert('pricing_headline');# Consent
Consent gate (consent)
xictraq.consent('granted' or 'denied') signals the visitor's consent for consent-required functions — in particular session recording. Recording starts only after 'granted' and stops on 'denied'; there is no auto-start on load. Cookieless measurement (pageviews, heatmap, forms, media) runs independently.
// Visitor consented -> recording may start
xictraq.consent('granted');
// Visitor declined -> recording does not start / stops
xictraq.consent('denied');# Complete API reference
All methods of window.xictraq at a glance. Optional parameters are marked with a question mark.
| Method | Parameters | Purpose |
|---|---|---|
xictraq.event | name (String), props? (Objekt) | Fire a custom event |
xictraq.identify | userId (String), traits? (Objekt) | Link the session to a customer/shop ID (personal data) |
xictraq.revenue | amount (Zahl), currency (String), orderId (String), extras? (tax, shipping, coupon) | Record an order / revenue |
xictraq.product | 'view', props (id, name, price, category) | Product view |
xictraq.cart | 'add' | 'remove', props (id, name, price, quantity) | Cart change |
xictraq.checkout | step (Zahl/Name), meta? (Objekt) | Checkout step |
xictraq.refund | orderId (String), amount (Zahl), currency (String) | Refund |
xictraq.paymentFailed | orderId? (String), amount? (Zahl), currency? (String), extras? (payment_method) | Failed payment |
xictraq.experiment | name (String) → Promise(variant) | Assign an A/B variant (Promise) |
xictraq.convert | name (String) | Report an A/B conversion |
xictraq.consent | 'granted' | 'denied' | Consent gate (controls session recording) |
xictraq.record | 'start' | 'stop' | Switch session recording on or off on this page (consent still required) |