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’);

Info
Set User Information:
When you want to set user info to be captured in the respondent data your can use setUserInfo method:

const userInfo = { "Email": "sample@test.com", Name: "Sample user", "Phone Number": "911234567890" };
window.surveysensum.setUserInfo(userInfo);

Info
Set Transaction Information:
When you want to save the transactional data in the respondent for example transaction amount, you can use setMedatadataInfo method:
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 ...
    • Survey Settings

      General settings like survey link expiration date, password protected surveys, survey access, etc can be modified in survey options. To view, these settings click on survey options in your builder These settings will help better the experience of ...
    • Survey Metrics

      The Survey Metric page gives you the frequency distribution of a survey and also each question in the survey. Visualize the responses using graphs here. This will give you an overview of the responses and its distribution metric that can help you ...
    • How can you use the DIY Dashboard?

      The DIY Dashboard is a solution from our side to solve your hassle of sharing multiple responses from different surveys with your teams in screenshots and multiple PowerPoint presentations.  With this Dashboard, you can collate all the responses ...