Skip to content

JavaScript trigger

Open the quiz in a modal when a shopper selects a storefront link or button. Use the Quiz ID from Setup › Integration. The Global script uses your Client ID.

Wait for the Global script so a slow load does not break the button. This example uses a link. Set its href to an existing inline quiz page so it can also work as a normal link.

Open the quiz from a link
<a id="neocom-open-quiz" href="/bike-finder">Find my product</a>
<script>
const quizLink = document.getElementById("neocom-open-quiz");
function enableQuizTrigger() {
quizLink.addEventListener("click", (event) => {
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
event.preventDefault();
Neocom.openAdvisorInModal("YOUR_QUIZ_ID");
});
}
if (window.Neocom) enableQuizTrigger();
else window.addEventListener("neocomloaded", enableQuizTrigger, { once: true });
</script>

For a button without a fallback page, render it disabled and enable it once the API is ready. Verify that the click opens the published quiz on your test page.

Use the optional second argument to include or exclude Scopes. For example, open a quiz limited to the category of the current page.

Open with Scopes
Neocom.openAdvisorInModal("YOUR_QUIZ_ID", {
includeScopes: ["scope1", "scope2"],
excludeScopes: ["scope3"],
});

The quiz opens full screen as an overlay. To keep your header or navigation visible above it, set Modal Top Margin in the Theme Designer, separately for mobile and desktop. Placement and wording: Where to place your quiz.