Skip to main content
All CollectionsCollectWebsite Channels - General
How to Show the Website Survey to a Specified Amount of Audience
How to Show the Website Survey to a Specified Amount of Audience

Decide if you want to show the zenloop survey only to some people.

L
Written by Lisa Rentrop
Updated over 2 years ago

It is possible to show the website survey to a specific percentage of people visiting the page using the simple math function showed below.

In the beginning, we specify the audience percentage we want to show the survey.
In this case it is:


min/max, so 1/20 = 5%

Then, if the value has been drawn, the Zenloop.recipient object will be populated and the survey will be shown.

JavaScript example below:
​

var min = 1,
max = 20,
random = Math.floor(Math.random() * (max - min + 1)) + min;

if (1 === random) {

var script = document.createElement("script");
script.onload = function() {

var Zenloop = window.Zenloop || {};
var date = Date.now();
Zenloop.recipient = {
identity: 'test@example.com',
identity_type: 'email',
first_name: 'John',
last_name: 'Doe',
date: date,
properties: {
color: 'red',
height: 100
}
};
};

script.src = "https://zenloop-website-overlay-production.s3.amazonaws.com/loader/zenloop-compatibility.load.min.js?survey=SURVEY_HASH_ID";

script.setAttribute("id", "zl-website-overlay-loader");
document.getElementsByTagName("body")[0].appendChild(script)

}


Where:
​SURVEY_HASH_ID has to be replaced by your survey HashID, and the Zenloop.recipient object has to be customised up to your needs.
​

Did this answer your question?