Track custom events

Custom event tracking records actions CROforce can't see on its own, sent from your code. Send an event from your own code when something happens that CROforce can't see on its own — a sign-up in your app, a completed order, a booked call.

On this pageSend an eventExamplesTrack purchases and revenueName your eventsTurn an event into a goalReact and Next.jsRespect visitor consentCheck that your events arrive

Updated November 28, 2026

Page views, clicks and form submissions are tracked automatically once the tracking script is installed — see Automatically tracked events. Use trackEvent for everything else.

Send an event

JavaScript
entailInsights.trackEvent('event-name', { property: 'value' });

Argument

Type

What it is

event_name

string

Required. The name you'll pick when you create a goal, like lead or purchase.

properties

object

Optional. Details about the event — a plan name, a form ID, an order value. Shown in Reports › Visitor Activity.

Safe to call early. The snippet creates entailInsights immediately. Calls made before the script finishes loading are queued and sent once it's ready.

entailInsights.capture() takes the same arguments and does the same thing; trackEvent is the name used throughout these docs.

Examples

Button click

JavaScript
document.querySelector('#book-demo').addEventListener('click', function () {
  entailInsights.trackEvent('schedule', { source: 'pricing-page' });
});

Form submit

JavaScript
document.querySelector('#newsletter-form').addEventListener('submit', function () {
  entailInsights.trackEvent('subscribe', { list: 'weekly-tips' });
});

After your API answers

JavaScript
async function startTrial(plan) {
  const response = await fetch('/api/trial', { method: 'POST', body: JSON.stringify({ plan }) });
  if (response.ok) {
    // Send it only once the sign-up really succeeded.
    entailInsights.trackEvent('start-trial', { plan });
  }
}

Track purchases and revenue

Send purchase on your order confirmation page. CROforce uses value to show revenue per page, campaign and test variant. The full list of order fields is in Track purchases and revenue.

JavaScript
entailInsights.trackEvent('purchase', {
  value: '129.90',          // order total
  currency: 'USD',
  orderId: 'A-10045',
  orderNumber: '10045',
  createdAt: '2026-11-24T10:15:00Z',
  products: [
    { productId: 'tee-01', sku: 'TEE-BLK-M', quantity: 2, price: '39.95', currency: 'USD' },
    { productId: 'cap-07', sku: 'CAP-NVY', quantity: 1, price: '50.00', currency: 'USD' },
  ],
});

On Shopify? Purchases are tracked for you by the CROforce app. Don't add this code too, or orders are counted twice.

Name your events

Use one of the built-in names when it fits — CROforce already knows what they mean and gives them a ready-made goal: lead, purchase, add-to-cart, start-trial, subscribe and more. For anything else, use short lowercase words joined by hyphens, like download-whitepaper.

Turn an event into a goal

An event on its own shows up in your reports. To count it as a conversion in campaigns and A/B tests, make it a goal:

  1. Go to Set up › Goals and click New Goal.
  2. Name it, pick the conversion type and set what each conversion is worth.
  3. Open Tracking, keep Event rules, and choose your event under Event. Add a filter if it should count only on some pages.
  4. Click Save.
The Edit Goal dialog on the Tracking tab, with Event rules selected, the Form submit event and a Current URL filter

A goal counts a conversion each time its event matches the rules.

React and Next.js

Call it from your event handler. The snippet in your document head makes entailInsights available on window.

JSX
export function UpgradeButton({ plan }) {
  const handleClick = () => {
    window.entailInsights?.trackEvent('initiate-checkout', { plan });
    // …go to checkout
  };
  return <button onClick={handleClick}>Upgrade</button>;
}

TypeScript

Add this declaration once, for example in global.d.ts:

TypeScript
interface EntailInsights {
  trackEvent(eventName: string, properties?: Record<string, unknown>): void;
  capture(eventName: string, properties?: Record<string, unknown>): void;
}

declare global {
  interface Window {
    entailInsights?: EntailInsights;
  }
}

export {};

When a visitor opts out, CROforce drops their events — including the ones you send with trackEvent. Connect these calls to your cookie banner:

JavaScript
entailInsights.opt_out_capturing();       // visitor declined
entailInsights.opt_in_capturing();        // visitor accepted
entailInsights.has_opted_out_capturing(); // true or false, once the script has loaded

More in Consent and privacy.

Check that your events arrive

  1. Trigger the event on your site.
  2. In CROforce, open Reports › Visitor Activity, go to All Actions and filter by its name. It usually shows up within a minute. See Events.
  3. Not there? Open DevTools › Network, filter by t.entail-insights.com and repeat the action — a request should go out within a few seconds. Events are sent in small batches, so one request can carry several.

Was this article helpful?

Try it on your own site

Add a popup, form or quiz to your site in a few minutes and see what it does for your conversions.