How to use Javascript trigger in survey embedding

How to use Javascript trigger in survey embedding

Here you will learn to use JavaScript trigger in your webpage for embedded survey

Use Javascript trigger if you want to trigger the survey on a specific action taken by the user on your website or web application.

Suppose a user just signed up to your platform and you want to show them the survey regarding the signup experience, in that case, you can just use this trigger to start the survey.

How to use it?

NOTE: Before starting with this section, you must have basic knowledge of the Javascript Language.

Step 1: Select the Javascript trigger from the targeting section.

Step 2: Enter an event name you would like to use as your trigger, only alphanumeric characters (a-z, A-Z, 0-9), underscores (_), and dashes (-) can be used in the trigger name. This field cannot be left blank.

Note: If a Javascript trigger is present on a page, it will cause the survey to show regardless of any other rules present.

Step 3: Click Done.

Step 4: Add trigger code to the website

In the example above, we’ve created a trigger called user_logs_in. Next, you will need to add the trigger code to your website:

window.surveysensum.startSurvey(‘user_logs_in’);

When you want to set user info to be captured in the respondent data your can use setUserInfo method. If you want to save the transactional data in the respondent for example transaction amount, you can use seetMedatadataInfo method:

const userInfo = { "Email": "sample@test.com", Name: "Sample user", "Phone Number": "911234567890" };
window.surveysensum.setUserInfo(userInfo);
const metadata = { "Sample Metadata 1": "Meta 1", "Sample Metadata 2": "Meta 2" };
window.surveysensum.setMetadataInfo(metadata);
window.surveysensum.startSurvey("transaction_completed")



    • Related Articles

    • How to Embed your Survey on a Website

      Embed survey to your web application This article will help you in Embedding your Survey from SurveySensum on a Website. Embedding in a website is an essential sharing method for collecting user feedback for customer validation and customer-driven ...
    • How to set up the targeting for the survey on your webpage

      This article will guide you to configure the events to launch the survey on your webpage. Targeting: You can choose when, where & how often you want to surveys your users. A. Let's start with Where to show the Survey You can either display the survey ...
    • API document for Sharing the survey via WhatsApp, SMS, Email

      What is SurveySensum Platform: SurveySensum is a SAAS application, using the application anyone can create multiple surveys. These surveys can be shared to the customers through multiple channels like WhatsApp, Email, SMS. Once customers receive the ...
    • Share Survey Via Email

      Share Survey Via Email share via Email is used when you want to send surveys directly to known respondents through their email addresses. This option is ideal for collecting feedback like NPS, CSAT, or post-interaction surveys. Use it when you need ...
    • How to activate and get the code snippet to embed the survey

      In this article you will get to know about activating the survey and generate the code-snippet for embedding in webpage Review and activate: Here you can check what the triggers are and also the appearance you have applied and activated in your ...