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
entailInsights.trackEvent('event-name', { property: 'value' });Argument | Type | What it is |
|---|---|---|
| string | Required. The name you'll pick when you create a goal, like |
| 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
document.querySelector('#book-demo').addEventListener('click', function () {
entailInsights.trackEvent('schedule', { source: 'pricing-page' });
});Form submit
document.querySelector('#newsletter-form').addEventListener('submit', function () {
entailInsights.trackEvent('subscribe', { list: 'weekly-tips' });
});After your API answers
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.
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:
- Go to Set up › Goals and click New Goal.
- Name it, pick the conversion type and set what each conversion is worth.
- Open Tracking, keep Event rules, and choose your event under Event. Add a filter if it should count only on some pages.
- Click Save.
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.
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:
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 {};Respect visitor consent
When a visitor opts out, CROforce drops their events — including the ones you send with trackEvent. Connect these calls to your cookie banner:
entailInsights.opt_out_capturing(); // visitor declined
entailInsights.opt_in_capturing(); // visitor accepted
entailInsights.has_opted_out_capturing(); // true or false, once the script has loadedMore in Consent and privacy.
Check that your events arrive
- Trigger the event on your site.
- In CROforce, open Reports › Visitor Activity, go to All Actions and filter by its name. It usually shows up within a minute. See Events.
- Not there? Open DevTools › Network, filter by
t.entail-insights.comand repeat the action — a request should go out within a few seconds. Events are sent in small batches, so one request can carry several.

/filters:quality(80)/cro-force/goalrules-1795547786684.png)