// The quiz data object stores all questions and their corresponding options
const quizData = {
q1: {
question: "What is your use case?",
subtext: "Select an option",
options: {
geo: {
label: "Bypassing geo-restrictions (e.g. YouTube)",
image: "https://incogniton.com/wp-content/uploads/2024/07/Incogniton_icon-Ellipse.svg",
result: {
content: "✅ Use our FREE unblocked proxies.",
readMoreLabel: "More info",
readMoreLink: "https://incogniton.com/knowledge%20center/guide-how-to-use-incognitons-free-unblocked-proxies/",
image: "https://incogniton.com/wp-content/uploads/2025/04/case-studies-proxy-3-e1744889424735.png"
}
},
multiple: {
label: "Multiple account management (e.g. Facebook)",
image: "https://incogniton.com/wp-content/uploads/2024/07/Incogniton_icon-Ellipse.svg",
next: "q2"
},
ad: {
label: "Ad spying",
image: "https://incogniton.com/wp-content/uploads/2024/07/Incogniton_icon-Ellipse.svg",
next: "q2"
},
ticket: {
label: "Ticketing",
image: "https://incogniton.com/wp-content/uploads/2024/07/Incogniton_icon-Ellipse.svg",
next: "q2"
}
}
},
q2: {
question: "What location do you need proxies from?",
subtext: "Choose a location",
options: {
us: {
label: "United States",
image: "https://incogniton.com/wp-content/uploads/2024/07/Incogniton_icon-Ellipse.svg",
result: {
content: "Buy from the Incogniton Proxy Shop.",
readMoreLabel: "More info",
readMoreLink: "https://incogniton.com/knowledge%20center/guide-how-to-buy-proxies-via-incognitons-proxy-store/",
image: "https://incogniton.com/wp-content/uploads/2025/04/case-studies-proxy-3-e1744889424735.png"
}
},
uk: {
label: "United Kingdom",
image: "https://incogniton.com/wp-content/uploads/2024/07/Incogniton_icon-Ellipse.svg",
result: {
content: "Buy from the Incogniton Proxy Shop.",
readMoreLabel: "More info",
readMoreLink: "https://incogniton.com/knowledge%20center/guide-how-to-buy-proxies-via-incognitons-proxy-store/",
image: "https://incogniton.com/wp-content/uploads/2025/04/case-studies-proxy-3-e1744889424735.png"
}
},
other: {
label: "Other countries",
image: "https://incogniton.com/wp-content/uploads/2024/07/Incogniton_icon-Ellipse.svg",
result: {
content: "Buy from one of our trusted partners.",
readMoreLabel: "More info",
readMoreLink: "https://incogniton.com/proxy-integrations/",
image: "https://incogniton.com/wp-content/uploads/2025/04/case-studies-proxy-3-e1744889424735.png"
}
}
}
}
};
// The current question being shown (starts with q1)
let currentQuestion = "q1";
// A stack to track the question history for back navigation
const questionHistory = [];
/**
* Initializes and starts the quiz
* - Resets the state
* - Clears previous results
* - Renders the first question
*/
function startQuiz() {
currentQuestion = "q1";
questionHistory.length = 0; // clear history
document.getElementById("quiz-container").style.display = "flex";
document.getElementById("result-container").style.display = "none";
document.getElementById("result-container").innerHTML = "";
document.getElementById("restart-btn").style.display = "none";
document.getElementById("quiz-content").innerHTML = "";
renderQuestion();
}
/**
* Renders the current question:
* - Displays question text and subtext
* - Dynamically creates answer buttons with images and labels
*/
function renderQuestion() {
const qData = quizData[currentQuestion];
const header = document.getElementById("quiz-header");
const contentDiv = document.getElementById("quiz-content");
header.innerHTML = "";
contentDiv.innerHTML = "";
// Inject question and optional subtext
header.innerHTML = `
${qData.question}
${qData.subtext ? `
${qData.subtext}
` : ""}
`;
// Loop through the options and generate buttons
for (let key in qData.options) {
const option = qData.options[key];
const btn = document.createElement("button");
btn.innerHTML = `
${option.image ? `
` : ""}
${option.label}
`;
// Set click behavior to handleAnswer
btn.onclick = () => handleAnswer(key);
contentDiv.appendChild(btn);
}
// Show the back button only if we have a previous step
document.getElementById("previous-btn").style.display = questionHistory.length > 0 ? "inline-block" : "none";
}
/**
* Handles user selecting an answer
* - If option has a `result`, show it
* - If option has a `next`, proceed to next question
*/
function handleAnswer(key) {
const selected = quizData[currentQuestion].options[key];
if (selected.result) {
document.getElementById("quiz-container").style.display = "none";
showResult(selected.result);
} else if (selected.next) {
questionHistory.push(currentQuestion); // save current question in history
currentQuestion = selected.next;
renderQuestion();
}
}
/**
* Navigate back to the previous question
*/
function goToPrevious() {
if (questionHistory.length > 0) {
currentQuestion = questionHistory.pop();
renderQuestion();
}
}
/**
* Displays the result block with:
* - Text
* - Optional image
* - Link to read more
*/
function showResult(resultObj) {
const resultContainer = document.getElementById("result-container");
let resultHTML = "";
if (resultObj.image) {
resultHTML += `

`;
}
if (resultObj.content) {
resultHTML += `
${resultObj.content}`;
}
if (resultObj.readMoreLabel && resultObj.readMoreLink) {
resultHTML += `
${resultObj.readMoreLabel}
`;
}
resultContainer.innerHTML = resultHTML;
resultContainer.style.display = "block";
document.getElementById("restart-btn").style.display = "inline-flex";
}
// Start quiz when the page finishes loading
document.addEventListener("DOMContentLoaded", startQuiz);