Open a popup from your code

Open a popup on button click, or after any action on your site, with one line of JavaScript. Call entailInsights.showPopup('POPUP_ID') to open a published popup at any moment your page decides — after a sign-up, on a custom button, when a cart passes a value.

On this pageOpen the popupFind the popup IDWait until CROforce has loadedExamplesIf the popup doesn't openNext steps

Updated November 28, 2026

Not set
Find it on the install page of your account. It stays in this browser and is never sent anywhere.

Use this when the built-in triggers can't express the moment — for example "after the visitor adds a third item to the cart". You need the tracking script on the page and a published popup.

Open the popup

JavaScript
entailInsights.showPopup('POPUP_ID');

Argument

Type

What it is

popupId

string

Required. The ID of a published popup — see
Find the popup ID
.

The popup opens at once. Its triggers, frequency and pages and devices don't apply: you decide when, where and how often. If another popup is already open, nothing happens.

A popup only for your code. Leave the popup's trigger unset — the Display tab reads choose when — so it never opens by itself, then publish it and open it with showPopup.

Find the popup ID

The ID is part of the popup's code snippet in the classic builder:

  1. Publish the popup, if it isn't yet.
  2. In the widget builder, open More actions and choose Open in Classic Builder, then confirm with Open Classic Builder.
  3. Click Copy Code Snippet at the bottom. It copies a line like the one below.
  4. The ID is the value of entail-widget-id. Close the classic builder without saving.
HTML
<div class="entail-ai-widget-6512ab34cd56ef7890123456" entail-widget-id="6512ab34cd56ef7890123456"></div>

Here the ID is 6512ab34cd56ef7890123456. Use that value — not the ID in the builder's web address, which is a different one.

Don't paste the snippet on your page. That line is for widgets that sit inside a page. A popup needs only the ID; pasting the line doesn't open it.

Wait until CROforce has loaded

The snippet in your page head creates entailInsights straight away, but showPopup only exists once the CROforce script has finished loading. A call from a click handler is almost always late enough. For code that runs as the page opens, check first, or use the init option loaded:

Check first

JavaScript
function openCroforcePopup(id) {
  if (window.entailInsights && typeof window.entailInsights.showPopup === 'function') {
    window.entailInsights.showPopup(id);
  }
}

loaded option

JavaScript
entailInsights.init('YOUR_SITE_TOKEN', {
  disable_decide: false,
  loaded: function (sdk) {
    // Runs once CROforce is ready.
    if (window.location.hash === '#offer') sdk.showPopup('POPUP_ID');
  },
});
Paste your site token at the top of the page to fill it in.

The loaded version edits the init line of your existing snippet — keep your own site token and any options already there.

Examples

Your own button

JavaScript
document.querySelector('#talk-to-sales').addEventListener('click', function () {
  entailInsights.showPopup('POPUP_ID');
});

After your code decides

JavaScript
function onCartUpdated(cart) {
  if (cart.items.length >= 3 && typeof entailInsights.showPopup === 'function') {
    entailInsights.showPopup('POPUP_ID');
  }
}

React

JSX
export function TalkToSalesButton() {
  return (
    <button onClick={() => window.entailInsights?.showPopup?.('POPUP_ID')}>
      Talk to sales
    </button>
  );
}

For a button that exists when the page loads, the no-code When they click something trigger does the same job — see When a popup shows.

If the popup doesn't open

What you see

What to do

entailInsights.showPopup is not a function

The call ran before CROforce loaded. Check first or use loaded, as above.

Nothing happens, no error

Check the ID is the entail-widget-id value, the popup is published, and no other popup is open.

The old version opens

You changed the popup but didn't click Publish Changes.

More help: Troubleshooting.

Next steps

Frequently asked questions

Do the popup's triggers, pages and frequency still apply?

No. showPopup opens the popup straight away, on any page and device, every time you call it. Only one rule stays: if another popup is already open, it doesn't open.

Does the popup have to be published?

Yes. Visitors can only see published popups. Publish it first, then use its ID.

Can I open a popup from a button without code?

Yes, if the button is inside another popup or widget. In the widget builder, set the button's When clicked action to Open another popup and pick the popup to open.

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.