Skip to content
GDPR compliant. Hosted in the EU.
14-day free trial →

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. Pageviews, Web Vitals and custom events can be analysed from the Starter plan; heatmaps, forms, media, e-commerce, identification, A/B testing and session recording require the Business plan.

# 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>
Behind the first-party proxy the snippet looks different — the API does not
If you serve the tracker from your own domain, you embed it as <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>
Most of the time you do not need any code
For reach, forms, media, heatmaps, Web Vitals as well as e-commerce on 25+ common shop systems (WooCommerce, Shopify, Shopware, Magento, PrestaShop and many more) everything runs automatically, and user identification in Shopware, Shopify, WooCommerce/WordPress, PrestaShop, Drupal, Joomla, TYPO3 and BigCommerce. Reach for the JS API only for custom events, coupon codes and refunds, identification in other systems, or custom/headless front-ends.
Availability by plan
Pageviews, outbound links and downloads, Web Vitals and custom events (xictraq.event) can be analysed from the Starter plan; on the Free plan the server accepts pageviews up to the Free quota, analysis starts with Starter. E-commerce (revenue, refund, paymentFailed, product, cart, checkout), identify, A/B testing (experiment, convert), heatmaps including click capture, form and media analytics and session recording require the Business plan: below it the server accepts these calls but does not store them, and experiment() resolves with null. The same applies to automatic e-commerce and customer detection.

# 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: at most 20 traits with simple values (text, number, yes/no), values longer than 255 characters are truncated. 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' });
Automatic detection without a JS call
For common shop systems the tracker detects logged-in customers automatically. Without a shop integration one of the three conventions below is enough — the manual identify call is then not needed.
<!-- 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">
<!-- optional: xictraq:user-type, xictraq:user-name, xictraq:company -->
<meta name="xictraq:user-type" content="b2b">

<!-- 3) Attribute on any element (optional data-user-type, data-company) -->
<body data-user-id="cust_10492" data-user-type="b2b">
Pass personal data sparingly
With identify the session is no longer pseudonymous: customer number, name and company are personal data. Automatic detection adopts name and company where your shop displays them; when calling it yourself, pass only what you need for the analysis. Email addresses and phone numbers belong neither in identify nor in event properties; the server drops traits that contain an email address, and an identifier (userId) in the form of an email address together with the whole call; use the customer number for it. The link itself is deleted no later than 365 days after the last visit, regardless of plan.

# Manual e-commerce

For common shops this runs automatically
For WooCommerce, Shopify, Shopware, Magento, PrestaShop and 20+ more systems the tracker captures cart, checkout and orders without code. Coupon code and refunds are passed there too with xictraq.revenue() and xictraq.refund(); you only need the other methods for custom or headless front-ends that are not detected automatically.

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. currency is optional; if it is missing, the tracker uses the page currency. extras is an optional object with tax, shipping, coupon, discount, items as well as payment_method and shipping_method; if payment and shipping method are missing, the tracker reads them from the page.

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, optionally sku, brand, variant and currency. If category, brand or sku are missing, the tracker reads them from the page (structured data such as JSON-LD, product details, breadcrumb navigation).

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, optionally category, sku, brand, variant and currency.

// 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. Payment and shipping method (payment_method, shipping_method) can be passed in meta; if they are missing, the tracker reads them from the page.

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. orderId and amount are required: the original order number and the refunded amount. currency is optional; if the currency code is missing, the tracker uses the page currency.

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 or the account is below the Business plan, 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');

# Complete API reference

All methods of window.xictraq at a glance. Optional parameters are marked with a question mark.

MethodParametersPurpose
xictraq.eventname (String), props? (Objekt)Fire a custom event
xictraq.identifyuserId (String), traits? (Objekt, max. 20)Link the session to a customer/shop ID (personal data, Business+)
xictraq.revenueamount (Zahl), currency? (String), orderId (String), extras? (tax, shipping, coupon, discount, items, payment_method, shipping_method)Record an order / revenue (Business+)
xictraq.product'view', props (id, name, price, category?, sku?, brand?, variant?, currency?)Product view (Business+)
xictraq.cart'add' | 'remove', props (id, name, price, quantity, category?, sku?, brand?, variant?, currency?)Cart change (Business+)
xictraq.checkoutstep (Zahl/Name), meta? (Objekt)Checkout step (Business+)
xictraq.refundorderId (String), amount (Zahl), currency? (String)Refund (Business+)
xictraq.paymentFailedorderId? (String), amount? (Zahl), currency? (String), extras? (payment_method)Failed payment (Business+)
xictraq.experimentname (String) → Promise(variant)Assign an A/B variant (Promise, Business+)
xictraq.convertname (String)Report an A/B conversion (Business+)
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, Business+)

Frequently asked questions

No. The standard snippet captures pageviews, clicks, forms, media, Web Vitals, heatmaps as well as e-commerce and identity for 25+ shop systems automatically; heatmaps, forms, media, e-commerce and identity are stored from the Business plan. You only need the JS API for custom events, coupon codes and refunds, or custom/headless front-ends.
First scan usually in under a minute

Let XICTRAQ® watch your website.

Free plan with no fixed term available. No credit card, no installation, no hidden fees.