Developers

Use the JavaScript SDK to track custom events and control CROforce from code.

How the snippet worksHow does a tracking snippet work? This page walks through CROforce's, line by line. The snippet creates a small placeholder called entailInsights, loads entail.js in the background and hands over every call you made in the meantime. It never blocks your page.init optionsThe second argument to entailInsights.init() changes how the SDK behaves on that page. Every option is optional — the snippet you copy already has the right defaults.Track custom eventsCustom 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.Automatically tracked eventsAutomatic event tracking records page views, clicks and form submissions without any extra code. Once the tracking script is on your site, CROforce records page views, clicks, form submissions and rage clicks by itself. You only write code for what happens outside the page, like a completed sign-up in your app.Visitor IDsCROforce gives every browser a random visitor ID and keeps it for a year, so it can count returning visitors and show each one the same test variant. Read it with get_distinct_id().Consent and privacyCookie consent and tracking go together: CROforce stops tracking a visitor who declines. Call entailInsights.opt_out_capturing() when a visitor declines tracking, and opt_in_capturing() when they accept. Opting out stops events and session recordings and deletes every CROforce cookie and storage entry.Single-page appsSingle-page app tracking needs no extra code in CROforce. CROforce notices every route change in a single-page app, sends a page view for the new URL and shows the widgets, popups and tests that apply to it.Redirect tests without flickerAn anti-flicker snippet keeps the original page hidden while a redirect test decides where to send the visitor. Add a two-line hide snippet to the top of a redirect test's page. The page stays blank for a split second while CROforce decides, then shows the original or sends the visitor to the variant — they never see the wrong page.Embed quizzes and widgets in HTMLTo embed a widget in HTML, you paste one empty tag where it should appear. Paste one empty <div> where the quiz or widget should appear. The tracking script finds it and fills it in, and later edits show up without changing the code.Preview URL parametersA URL parameter can force an A/B test variant, so you can see each version on demand. Add ?test_variant=test to a page's URL to see your test's variant, or ?test_variant=control to see the original. Visits with these parameters don't count in your test results.Domains to allowIf your site sends a Content-Security-Policy header, allow cdn.entail-insights.com, t.entail-insights.com and widgets.entail.ai. Add entail-assets.com and Google Fonts so widgets show their images and fonts.TroubleshootingTracking script not working? Start with these checks in your browser. Start in your browser: open your site, press F12 and look at the Network tab for entail.js and requests to t.entail-insights.com. Most problems show up there within a minute.