All Collections
Run web surveys
Website survey targeting
Show your survey after a JavaScript event
Show your survey after a JavaScript event

Display your survey based on your visitors actions on your website, like clicking a button, or navigating to a specific feature

Agnieszka avatar
Written by Agnieszka
Updated over a week ago

JavaScript triggers allow you to display a survey after a visitor clicks a button or encounters a JavaScript event on your website or web app. This feature allows you to:

  • target users that added a specific product to their basket or used a coupon in the cart, so you can increase a conversion rate and sales;

  • show a survey on a specific section of your dashboard/app to inquire about your user's experience;

  • add a specific button in the navigation of your product to let the user decide when he wants to leave feedback.

In this article, you'll learn how to take advantage of our JavaScript API while targeting a survey.

📌 This feature is available on some of the plans. Please visit our Pricing page or reach out to us to learn more by dropping us a line at or talking to us on chat 👉.

Step 1. Install the Survicate Tracking code

To be able to trigger a website or in-product survey after a JavaScript event, it's necessary to first install the Survicate tracking code on your website.

Please follow this guide to set it up.

Step 2. Adjust the JavaScript code

In order to trigger a survey on your website to show it to the visitors after a JavaScript event, you should start a specific script upon action with the showSurvey method, which makes it easy to show an arbitrary survey based on the given survey’s id.


To find the id, please open a survey in your Survicate Panel, and it will be visible in the URL after surveys/:

💡You can also choose to show the survey not immediately after someone enters the page, but you can change its default behavior.

To do this, you should modify the code as in this example:

var options = {
forceDisplay: true,
displayMethod: 'delayed',
displayOptions: {
delay: 5

_sva.showSurvey('id', options);

Options are a parameter used to specify the display details. All of them, as well as their descriptions, can be found here.

Please ask a developer to install these triggers - it should take just a few minutes of their work. To make sure it works properly, provide them with our JavaScript documentation.

Optional: Overwrite targeting settings present in your Survicate Panel

If you choose to display a survey using JavaScript, you don't have to set up the targeting in the Target tab of your Website or in-product survey.

However, if you have the targeting set up, the survey will be displayed while those conditions are met OR on the JavaScript event.

💡If you would like to only use JavaScript targeting, you can choose to disable automatic targeting.


I don't see the survey, even with the JavaScript code installed

Please make sure your Survicate tracking code is installed on the webpage you're trying to show the survey on. To do this, open your website in the browser and view the Developer Tools. Open the Console, write _svc, and click Enter.

If the code is installed properly, you should receive a message with your workspaceKey:

When you see a red error message, as below, it means that you need to try installing the Survicate tracking code once again.

I don't see the survey even though I use the _sva.showSurvey method

If your survey isn't shown, please use this expanded code:

window.addEventListener('SurvicateReady', function() {

📞 If you have any questions about triggering a survey after a JavaScript event, please reach out to us at or strike up a chat conversation 👉

Did this answer your question?