Checking the quota before offering video

Voxpopme help team -

Once the video question has reached it's quota, or the question has expired, the respondent will see the message 'Sorry we already have enough videos, thanks for trying though!'. If you'd like to improve the user experience, we recommend implementing the snippet of Javascript code below.

This snippet will need to be implemented on the page before the video capture widget within the survey. The Javascript will check if the question is active. If the question is active, the respondent will be directed to the capture widget page. If the question is inactive, either because the quota is full or the question has expired, the respondent can be directed to an alternative page within the survey. We would suggest directing the respondent to a open-end text question at this point. 

The code snippet below highlights what needs to be replaced in the Javascript code when you are implementing it. Please note this will only work if your survey is over https, otherwise the Ajax request will fail.

/**
 * Note: This will only work if your survey is over https otherwise the Ajax request will fail
 *
 * Fire this checkStatus() function at the appropriate point in the survey
 *
 * REPLACE: The Project identifier provided to you (this is the same as the one used in the widget link)
 *
 * REPLACE: Add in logic for sending the user to the video question
 * REPLACE: Add in logic for sending the user to a fallback text question
 *
 */
function checkStatus() {
	var xhttp = new XMLHttpRequest();
	xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) { if ( xhttp.responseText ) { var response = JSON.parse(xhttp.responseText); //The question status is `active` if ( response.status && 'active' === response.status ) { //SEND THE USER TO THE VIDEO QUESTION } //The question status is `inactive` or `quota_full` else { //SEND THE USER TO THE TEXT QUESTION } }
} }; xhttp.open("GET", "https://www.voxpopme.com/recordStatus/[REPLACE WITH YOUR PROJECT IDENT]", true); xhttp.send(); }
Have more questions? Submit a request

0 Comments

Article is closed for comments.