Skip to content
GDPR compliant. Hosted in DE.
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.

# 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.

# 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' });
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">

<!-- 3) Attribute on any element -->
<body data-user-id="cust_10492">
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. 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');

# 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)Link the session to a customer/shop ID (personal data)
xictraq.revenueamount (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.checkoutstep (Zahl/Name), meta? (Objekt)Checkout step
xictraq.refundorderId (String), amount (Zahl), currency (String)Refund
xictraq.paymentFailedorderId? (String), amount? (Zahl), currency? (String), extras? (payment_method)Failed payment
xictraq.experimentname (String) → Promise(variant)Assign an A/B variant (Promise)
xictraq.convertname (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)

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. You only need the JS API for custom events, coupon codes and refunds, or custom/headless front-ends.
Start in 60 seconds

Let XICTRAQ watch your website.

Permanent free plan available. No credit card, no installation, no hidden fees.