Skip to content

Triggering Surveys

You can open the Appzi survey widget using JavaScript. This is useful for use cases like triggering a survey from a custom button or based on specific user interactions.

Appzi exposes a global variable named appzi. You can use the appzi.openSurvey() method to show a survey.

<button onclick="appzi && appzi.openSurvey('CONFIG_ID')">Leave Feedback</button>

Replace CONFIG_ID with the ID of the survey you want to open.

You can use the data-az-l attribute to mark any element as a trigger for the survey.

<a data-az-l="CONFIG_ID">Leave Feedback</a>

To automatically trigger a survey when the page loads, you can use the ready callback inside the appziSettings object. This gives you access to the Appzi instance once it’s available.

<script>
window.appziSettings = {
ready: function (appzi) {
appzi.openSurvey("CONFIG_ID");
},
};
</script>

Where CONFIG_ID is the id of the survey you want to open.