Appzi Docs

Triggering surveys via JS

Triggering surveys via JS

You can choose to open the button via JS, a few common cases would be custom buttons or triggering the survey based on user interactions.

Triggering a survey via appzi.openSurvey

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

<button
onclick="appzi && appzi.openSurvey('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')"
>
Leave Feedback
</button>
where `xxxxxx....` is the id of the survey you want to open.

Triggering the survey via data-az-l attribute

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

<a data-az-l="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">Leave Feedback</a>

Triggering a survey on page load

If you would like to trigger the survey based immediately as the page loads - the ready event in appziSettings can be used to obtain the Appzi instance as soon as its available.

<script>
window.appziSettings = {
ready: function(appzi) {
appzi.openWidget('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
}
}
</script>
where `xxxxxx....` is the id of the survey you want to open.