<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fitness Gear Quiz - Find Your Perfect Equipment</title>
<style>
body { font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; background: #f4f4f4; }
.quiz-container { background: white; padding: 30px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
h1 { text-align: center; color: #333; }
.question { margin-bottom: 20px; }
.question h3 { margin-bottom: 15px; color: #555; }
label { display: block; margin-bottom: 10px; padding: 12px; border: 2px solid #ddd; border-radius: 5px; cursor: pointer; transition: all 0.3s; }
label:hover { border-color: #4CAF50; background: #f9f9f9; }
input[type="radio"] { margin-right: 10px; }
button { background: #4CAF50; color: white; padding: 15px 30px; border: none; border-radius: 5px; font-size: 18px; cursor: pointer; width: 100%; margin-top: 20px; }
button:hover { background: #45a049; }
button:disabled { background: #ccc; cursor: not-allowed; }
.progress { height: 5px; background: #ddd; border-radius: 5px; margin-bottom: 20px; overflow: hidden; }
.progress-bar { height: 100%; background: #4CAF50; width: 0%; transition: width 0.3s; }
.result { text-align: center; padding: 40px; }
.recommendation { background: #e8f5e8; padding: 20px; border-radius: 10px; margin: 20px 0; }
.lead-form { background: #f9f9f9; padding: 20px; border-radius: 10px; }
input[type="email"], input[type="text"] { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 5px; box-sizing: border-box; }
.analytics-debug { position: fixed; bottom: 10px; right: 10px; background: #333; color: white; padding: 10px; font-size: 12px; border-radius: 5px; max-width: 300px; display: none; }
.hidden { display: none; }
</style>
</head>
<body>
<div class="quiz-container">
<h1>🏋️♂️ Fitness Gear Quiz</h1>
<div class="progress">
<div class="progress-bar" id="progressBar"></div>
</div>
<div id="quizContent"></div>
<div id="result" class="result hidden">
<h2>Your Perfect Gear Recommendation</h2>
<div id="recommendation" class="recommendation"></div>
<div class="lead-form">
<h3>Get Your Personalized Quote & Free Guide!</h3>
<input type="text" id="name" placeholder="Full Name">
<input type="email" id="email" placeholder="Email Address">
<button onclick="submitLead()">Send Me the Deal! 🚀</button>
</div>
</div>
</div>
<div id="analyticsDebug" class="analytics-debug"></div>
<script>
// === QUESTION GRAPH & SCORING SYSTEM ===
// Scoring categories: experience (0-10), budget (low=0,med=5,high=10), space (small=0,med=5,large=10), intensity (low=0,high=10)
// Products: based on score thresholds
const products = {
beginnerHomeDumbbells: { name: 'Adjustable Dumbbells Set ($99)', desc: 'Perfect for beginners, small space, low budget.', route: '/products/dumbbells?quiz=beginner' },
treadmillPro: { name: 'Compact Treadmill ($499)', desc: 'Cardio for home, medium space/budget.', route: '/products/treadmill?quiz=cardio' },
powerRackElite: { name: 'Power Rack + Weights ($1499)', desc: 'Advanced lifting, large space, high budget.', route: '/products/rack?quiz=elite' },
yogaMatKit: { name: 'Yoga & Mobility Kit ($79)', desc: 'Low intensity, any space.', route: '/products/yoga?quiz=lowint' }
};
const questions = [
{
id: 'q1',
text: 'What is your main fitness goal?',
options: [
{ text: 'Weight Loss / Cardio', score: { goal: 'loss' }, next: 'q2' },
{ text: 'Build Muscle / Strength', score: { goal: 'gain' }, next: 'q2' },
{ text: 'Flexibility / Yoga', score: { goal: 'flex' }, next: 'q2' },
{ text: 'General Fitness', score: { goal: 'general' }, next: 'q2' }
]
},
{
id: 'q2',
text: 'What is your experience level?',
options: [
{ text: 'Beginner (new to fitness)', score: { experience: 2 }, next: 'q3' },
{ text: 'Intermediate (workout 2-3x/week)', score: { experience: 5 }, next: 'q3' },
{ text: 'Advanced (serious gym-goer)', score: { experience: 10 }, next: 'q3' }
]
},
{
id: 'q3',
text: 'What is your monthly budget for gear?',
options: [
{ text: 'Under $100', score: { budget: 2 }, next: 'q4' },
{ text: '$100 - $500', score: { budget: 5 }, next: 'q4' },
{ text: 'Over $500', score: { budget: 10 }, next: 'q4' }
]
},
{
id: 'q4',
text: 'How much space do you have for equipment?',
options: [
{ text: 'Small apartment (under 10 sq ft)', score: { space: 2 }, next: 'q5' },
{ text: 'Medium room (10-50 sq ft)', score: { space: 5 }, next: 'q5' },
{ text: 'Dedicated gym space (large)', score: { space: 10 }, next: 'q5' }
]
},
{
id: 'q5',
text: 'Preferred workout intensity?',
options: [
{ text: 'Low (yoga, light cardio)', score: { intensity: 2 }, next: 'end' },
{ text: 'Medium (moderate weights/cardio)', score: { intensity: 5 }, next: 'end' },
{ text: 'High (heavy lifting/HIIT)', score: { intensity: 10 }, next: 'end' }
]
}
];
// Build question graph: map id -> question
const questionGraph = {};
questions.forEach(q => questionGraph[q.id] = q);
// === STATE MANAGEMENT ===
let currentQuestionId = 'q1';
let scores = { experience: 0, budget: 0, space: 0, intensity: 0, goal: '' };
let userPath = []; // Track visited questions
let analytics = {
starts: 0,
questionViews: {},
answers: {},
completions: 0,
leads: 0,
dropoffs: {}
};
// Init
function init() {
loadState();
trackEvent('quiz_start');
render();
}
function loadState() {
const saved = localStorage.getItem('fitnessQuiz');
if (saved) {
const state = JSON.parse(saved);
currentQuestionId = state.currentQuestionId || 'q1';
scores = state.scores || scores;
userPath = state.userPath || [];
}
}
function saveState() {
localStorage.setItem('fitnessQuiz', JSON.stringify({ currentQuestionId, scores, userPath }));
}
// === RENDERING ===
function render() {
const content = document.getElementById('quizContent');
const result = document.getElementById('result');
const progress = document.getElementById('progressBar');
if (currentQuestionId === 'end') {
content.classList.add('hidden');
result.classList.remove('hidden');
showResults();
progress.style.width = '100%';
trackEvent('quiz_complete');
analytics.completions++;
saveAnalytics();
return;
}
const q = questionGraph[currentQuestionId];
userPath.push(currentQuestionId);
trackEvent(`view_${currentQuestionId}`);
let html = `<div class="question">
<h3>${q.text}</h3>
${q.options.map((opt, i) => `
<label>
<input type="radio" name="${q.id}" value="${i}" onchange="selectAnswer('${q.id}', ${i})">
${opt.text}
</label>
`).join('')}
<button id="nextBtn" onclick="nextQuestion()" disabled>Next →</button>
</div>`;
content.innerHTML = html;
progress.style.width = `${((userPath.length / 5) * 100)}%`; // 5 questions
saveState();
}
function selectAnswer(qId, optIndex) {
const q = questionGraph[qId];
const opt = q.options[optIndex];
Object.assign(scores, opt.score);
trackEvent(`answer_${qId}_${optIndex}`);
document.getElementById('nextBtn').disabled = false;
analytics.answers[qId] = (analytics.answers[qId] || 0) + 1;
saveAnalytics();
}
function nextQuestion() {
currentQuestionId = questionGraph[currentQuestionId].options[0].next; // Assume all options same next (simple linear w/ scoring)
render();
}
// === RESULTS & ROUTING ===
function showResults() {
const totalExp = scores.experience;
const totalBudget = scores.budget;
const totalSpace = scores.space;
const totalInt = scores.intensity;
let recommendation;
if (totalExp < 4 && totalBudget < 4 && totalSpace < 4) {
recommendation = products.beginnerHomeDumbbells;
} else if (scores.goal === 'loss' || totalInt < 6) {
recommendation = products.treadmillPro;
} else if (totalExp >= 7 && totalSpace >= 7 && totalBudget >= 7) {
recommendation = products.powerRackElite;
} else {
recommendation = products.yogaMatKit;
}
document.getElementById('recommendation').innerHTML = `
<h3>${recommendation.name}</h3>
<p>${recommendation.desc}</p>
<a href="${recommendation.route}" target="_blank" style="background: #FF5722; color: white; padding: 12px 24px; text-decoration: none; border-radius: 5px; display: inline-block;">Buy Now - Save 10% with Quiz!</a>
`;
}
// === LEAD CAPTURE ===
function submitLead() {
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
if (!name || !email) return alert('Please fill in your details!');
// Simulate API call
console.log('Lead captured:', { name, email, scores, recommendation: products });
trackEvent('lead_captured');
analytics.leads++;
alert('Thanks! Check your email for your quote & guide. 🎉');
saveAnalytics();
// Reset for new user? localStorage.removeItem('fitnessQuiz');
}
// === CONVERSION ANALYTICS ===
function trackEvent(event) {
analytics.questionViews[event] = (analytics.questionViews[event] || 0) + 1;
logAnalytics(`Event: ${event}`);
}
function saveAnalytics() {
localStorage.setItem('fitnessQuizAnalytics', JSON.stringify(analytics));
}
function logAnalytics(msg) {
document.getElementById('analyticsDebug').innerHTML += msg + '<br>';
document.getElementById('analyticsDebug').style.display = 'block';
console.log('Analytics:', analytics);
}
// Load initial analytics
const savedAnalytics = localStorage.getItem('fitnessQuizAnalytics');
if (savedAnalytics) {
Object.assign(analytics, JSON.parse(savedAnalytics));
}
analytics.starts++;
// Start the quiz
init();
</script>
</body>
</html>
🚀 How This Works (Product Quiz/Assistant for Demand Capture)
1. Question Graph (Branching Logic)
- Defined in
questions array as a graph: Each question has id, text, options (with score delta & next id).
- Currently linear for simplicity (all options lead to same next), but easily branchable (e.g., change
next per option).
- State persists via
localStorage (resume mid-quiz).
2. Scoring System
- Multi-dimensional scores:
experience, budget, space, intensity, goal.
- Answers accumulate scores (e.g., beginner = +2 experience).
- At end, thresholds route to products (e.g., low scores → cheap dumbbells).
3. Routing
- Dynamic recommendations based on scores.
- Each product has a
route (e.g., /products/dumbbells?quiz=beginner) for sales funnel.
- Progress bar & Next button guide flow.
4. Conversion Analytics
- Tracks: starts, question views/answers, completions, leads, dropoffs.
- Events logged to console, on-screen debug (toggle via dev tools),
localStorage.
- Lead capture: Email form at end → "conversion" (simulates API; integrate with Zapier/Mailchimp).
- Metrics example: Completion rate =
completions / starts.
Deployment & Customization
- Single HTML file → Host on Netlify/Vercel (free).
- Customize: Edit
questions, products, add branches (e.g., opt.next = 'q6' conditionally).
- Real Analytics: Replace
console.log with GA4/PostHog (gtag('event', 'quiz_complete')).
- Advanced: Add A/B testing on questions, server-side leads (Firebase/Netlify Functions).
Test it: Open in browser, complete quiz → See rec + lead form. Refresh analytics in console/localStorage. Perfect for demand gen! 💥
Need tweaks for your product (e.g., SaaS tools)? Let me know!