Spaces:
Running
Running
File size: 34,972 Bytes
7fc4ba3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Marketing Funnel Dashboard</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.funnel-arrow {
position: relative;
height: 60px;
background: #3b82f6;
width: 100%;
margin: 20px 0;
}
.funnel-arrow:after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 0;
height: 0;
border-left: 30px solid white;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
}
.funnel-arrow:before {
content: '';
position: absolute;
right: 0;
bottom: 0;
width: 0;
height: 0;
border-left: 30px solid #3b82f6;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
}
.conversion-rate {
position: absolute;
top: -30px;
left: 50%;
transform: translateX(-50%);
background: white;
padding: 2px 8px;
border-radius: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
font-weight: bold;
color: #3b82f6;
}
.progress-bar {
height: 10px;
border-radius: 5px;
background-color: #e5e7eb;
overflow: hidden;
}
.progress-fill {
height: 100%;
border-radius: 5px;
transition: width 0.3s ease;
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<div class="container mx-auto px-4 py-8 max-w-6xl">
<header class="mb-8">
<h1 class="text-3xl font-bold text-gray-800">Marketing Funnel Dashboard</h1>
<p class="text-gray-600">Track and optimize your marketing funnel performance</p>
</header>
<!-- Dashboard Section -->
<section class="mb-10 bg-white rounded-xl shadow-md p-6">
<div class="flex justify-between items-center mb-6">
<h2 class="text-xl font-semibold text-gray-700">Performance Dashboard</h2>
<div class="flex space-x-3">
<button id="exportBtn" class="flex items-center px-4 py-2 bg-blue-50 text-blue-600 rounded-lg hover:bg-blue-100 transition">
<i class="fas fa-file-export mr-2"></i> Export CSV
</button>
<button id="webhookBtn" class="flex items-center px-4 py-2 bg-green-50 text-green-600 rounded-lg hover:bg-green-100 transition">
<i class="fas fa-paper-plane mr-2"></i> Send to Webhook
</button>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-5 gap-4 mb-6">
<!-- Clicks Card -->
<div class="bg-blue-50 p-4 rounded-lg">
<div class="flex justify-between items-start">
<div>
<p class="text-sm font-medium text-blue-600">Clicks</p>
<h3 class="text-2xl font-bold text-blue-800" id="dashboardClicks">0</h3>
</div>
<div class="bg-blue-100 p-2 rounded-lg">
<i class="fas fa-mouse-pointer text-blue-600"></i>
</div>
</div>
<div class="mt-2">
<p class="text-xs text-blue-700">Cost per Click: <span id="cpcDashboard">$0.00</span></p>
</div>
</div>
<!-- Elementor Leads Card -->
<div class="bg-purple-50 p-4 rounded-lg">
<div class="flex justify-between items-start">
<div>
<p class="text-sm font-medium text-purple-600">Elementor Leads</p>
<h3 class="text-2xl font-bold text-purple-800" id="dashboardElementorLeads">0</h3>
</div>
<div class="bg-purple-100 p-2 rounded-lg">
<i class="fas fa-envelope text-purple-600"></i>
</div>
</div>
<div class="mt-2">
<p class="text-xs text-purple-700">Conv. Rate: <span id="elConvRateDashboard">0%</span></p>
<p class="text-xs text-purple-700">Cost per Lead: <span id="elCplDashboard">$0.00</span></p>
</div>
</div>
<!-- Steve Leads Card -->
<div class="bg-indigo-50 p-4 rounded-lg">
<div class="flex justify-between items-start">
<div>
<p class="text-sm font-medium text-indigo-600">Steve Leads</p>
<h3 class="text-2xl font-bold text-indigo-800" id="dashboardSteveLeads">0</h3>
</div>
<div class="bg-indigo-100 p-2 rounded-lg">
<i class="fas fa-user-tie text-indigo-600"></i>
</div>
</div>
<div class="mt-2">
<p class="text-xs text-indigo-700">Conv. Rate: <span id="slConvRateDashboard">0%</span></p>
<p class="text-xs text-indigo-700">Cost per Lead: <span id="slCplDashboard">$0.00</span></p>
</div>
</div>
<!-- App Submissions Card -->
<div class="bg-teal-50 p-4 rounded-lg">
<div class="flex justify-between items-start">
<div>
<p class="text-sm font-medium text-teal-600">App Submissions</p>
<h3 class="text-2xl font-bold text-teal-800" id="dashboardAppSubmissions">0</h3>
</div>
<div class="bg-teal-100 p-2 rounded-lg">
<i class="fas fa-file-alt text-teal-600"></i>
</div>
</div>
<div class="mt-2">
<p class="text-xs text-teal-700">Conv. Rate: <span id="asConvRateDashboard">0%</span></p>
<p class="text-xs text-teal-700">Cost per App: <span id="asCpaDashboard">$0.00</span></p>
</div>
</div>
<!-- Questionnaires Card -->
<div class="bg-green-50 p-4 rounded-lg">
<div class="flex justify-between items-start">
<div>
<p class="text-sm font-medium text-green-600">Questionnaires</p>
<h3 class="text-2xl font-bold text-green-800" id="dashboardQuestionnaires">0</h3>
</div>
<div class="bg-green-100 p-2 rounded-lg">
<i class="fas fa-clipboard-check text-green-600"></i>
</div>
</div>
<div class="mt-2">
<p class="text-xs text-green-700">Conv. Rate: <span id="mqConvRateDashboard">0%</span></p>
<p class="text-xs text-green-700">Cost per Qnr: <span id="mqCpqDashboard">$0.00</span></p>
</div>
</div>
</div>
<!-- Overall Conversion Rate -->
<div class="bg-white border border-gray-200 rounded-lg p-4 mb-6">
<h3 class="font-medium text-gray-700 mb-2">Overall Conversion Rate</h3>
<div class="flex items-center">
<div class="w-full bg-gray-100 rounded-full h-6">
<div id="overallProgress" class="progress-fill h-6 rounded-full bg-gradient-to-r from-blue-500 to-green-500" style="width: 0%"></div>
</div>
<span id="overallConversion" class="ml-4 font-bold text-gray-700">0%</span>
</div>
</div>
<!-- Funnel Visualization -->
<div class="bg-white p-6 rounded-xl border border-gray-200">
<h3 class="font-medium text-gray-700 mb-4">Funnel Flow</h3>
<div class="flex items-center justify-between mb-2">
<div class="text-center w-1/5">
<div class="bg-blue-100 text-blue-800 font-bold py-2 px-4 rounded-lg">Clicks</div>
</div>
<div class="text-center w-1/5 relative">
<div class="funnel-arrow">
<div class="conversion-rate" id="clickToElRate">0%</div>
</div>
<div class="bg-purple-100 text-purple-800 font-bold py-2 px-4 rounded-lg">Elementor Leads</div>
</div>
<div class="text-center w-1/5 relative">
<div class="funnel-arrow">
<div class="conversion-rate" id="elToSlRate">0%</div>
</div>
<div class="bg-indigo-100 text-indigo-800 font-bold py-2 px-4 rounded-lg">Steve Leads</div>
</div>
<div class="text-center w-1/5 relative">
<div class="funnel-arrow">
<div class="conversion-rate" id="slToAsRate">0%</div>
</div>
<div class="bg-teal-100 text-teal-800 font-bold py-2 px-4 rounded-lg">App Submissions</div>
</div>
<div class="text-center w-1/5 relative">
<div class="funnel-arrow">
<div class="conversion-rate" id="asToMqRate">0%</div>
</div>
<div class="bg-green-100 text-green-800 font-bold py-2 px-4 rounded-lg">Questionnaires</div>
</div>
</div>
</div>
</section>
<!-- Data Input Section -->
<section class="mb-10 bg-white rounded-xl shadow-md p-6">
<h2 class="text-xl font-semibold text-gray-700 mb-6">Data Input</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<div class="mb-4">
<label for="clicks" class="block text-sm font-medium text-gray-700 mb-1">Clicks</label>
<input type="number" id="clicks" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500" oninput="updateCalculations()" placeholder="Enter number of clicks">
</div>
<div class="mb-4">
<label for="elementor_leads" class="block text-sm font-medium text-gray-700 mb-1">Elementor Leads</label>
<input type="number" id="elementor_leads" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500" oninput="updateCalculations()" placeholder="Enter number of leads">
</div>
<div class="mb-4">
<label for="steve_leads" class="block text-sm font-medium text-gray-700 mb-1">Steve Leads</label>
<input type="number" id="steve_leads" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500" oninput="updateCalculations()" placeholder="Enter number of leads">
</div>
</div>
<div>
<div class="mb-4">
<label for="application_submissions" class="block text-sm font-medium text-gray-700 mb-1">Application Submissions</label>
<input type="number" id="application_submissions" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500" oninput="updateCalculations()" placeholder="Enter number of submissions">
</div>
<div class="mb-4">
<label for="marketing_questionnaires" class="block text-sm font-medium text-gray-700 mb-1">Marketing Questionnaires</label>
<input type="number" id="marketing_questionnaires" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500" oninput="updateCalculations()" placeholder="Enter number of questionnaires">
</div>
<div class="mb-4">
<label for="ad_spend" class="block text-sm font-medium text-gray-700 mb-1">Total Ad Spend ($)</label>
<input type="number" step="0.01" id="ad_spend" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500" oninput="updateCalculations()" placeholder="Enter total ad spend">
</div>
</div>
</div>
</section>
<!-- Target Setting Section -->
<section class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-xl font-semibold text-gray-700 mb-6">Target vs Actual Performance</h2>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Metric</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Target</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actual</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Clicks</td>
<td class="px-6 py-4 whitespace-nowrap">
<input type="number" id="targetClicks" class="w-24 px-3 py-1 border border-gray-300 rounded-md" placeholder="Target" oninput="updateTargetComparisons()">
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500" id="actualClicks">0</td>
<td class="px-6 py-4 whitespace-nowrap">
<span id="clickStatus" class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">-</span>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Elementor Leads</td>
<td class="px-6 py-4 whitespace-nowrap">
<input type="number" id="targetElementorLeads" class="w-24 px-3 py-1 border border-gray-300 rounded-md" placeholder="Target" oninput="updateTargetComparisons()">
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500" id="actualElementorLeads">0</td>
<td class="px-6 py-4 whitespace-nowrap">
<span id="elementorLeadStatus" class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">-</span>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Steve Leads</td>
<td class="px-6 py-4 whitespace-nowrap">
<input type="number" id="targetSteveLeads" class="w-24 px-3 py-1 border border-gray-300 rounded-md" placeholder="Target" oninput="updateTargetComparisons()">
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500" id="actualSteveLeads">0</td>
<td class="px-6 py-4 whitespace-nowrap">
<span id="steveLeadStatus" class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">-</span>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">App Submissions</td>
<td class="px-6 py-4 whitespace-nowrap">
<input type="number" id="targetAppSubmissions" class="w-24 px-3 py-1 border border-gray-300 rounded-md" placeholder="Target" oninput="updateTargetComparisons()">
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500" id="actualAppSubmissions">0</td>
<td class="px-6 py-4 whitespace-nowrap">
<span id="appSubmissionStatus" class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">-</span>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Questionnaires</td>
<td class="px-6 py-4 whitespace-nowrap">
<input type="number" id="targetQuestionnaires" class="w-24 px-3 py-1 border border-gray-300 rounded-md" placeholder="Target" oninput="updateTargetComparisons()">
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500" id="actualQuestionnaires">0</td>
<td class="px-6 py-4 whitespace-nowrap">
<span id="questionnaireStatus" class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">-</span>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Overall Conversion Rate</td>
<td class="px-6 py-4 whitespace-nowrap">
<input type="number" id="targetConversionRate" class="w-24 px-3 py-1 border border-gray-300 rounded-md" placeholder="Target %" oninput="updateTargetComparisons()">
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500" id="actualConversionRate">0%</td>
<td class="px-6 py-4 whitespace-nowrap">
<span id="conversionRateStatus" class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">-</span>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
<script>
// Update all calculations when any input changes
function updateCalculations() {
// Get input values
const clicks = parseInt(document.getElementById('clicks').value) || 0;
const elementorLeads = parseInt(document.getElementById('elementor_leads').value) || 0;
const steveLeads = parseInt(document.getElementById('steve_leads').value) || 0;
const appSubmissions = parseInt(document.getElementById('application_submissions').value) || 0;
const questionnaires = parseInt(document.getElementById('marketing_questionnaires').value) || 0;
const adSpend = parseFloat(document.getElementById('ad_spend').value) || 0;
// Update dashboard numbers
document.getElementById('dashboardClicks').textContent = clicks.toLocaleString();
document.getElementById('dashboardElementorLeads').textContent = elementorLeads.toLocaleString();
document.getElementById('dashboardSteveLeads').textContent = steveLeads.toLocaleString();
document.getElementById('dashboardAppSubmissions').textContent = appSubmissions.toLocaleString();
document.getElementById('dashboardQuestionnaires').textContent = questionnaires.toLocaleString();
// Calculate conversion rates
const clickToElRate = clicks > 0 ? (elementorLeads / clicks * 100) : 0;
const elToSlRate = elementorLeads > 0 ? (steveLeads / elementorLeads * 100) : 0;
const slToAsRate = steveLeads > 0 ? (appSubmissions / steveLeads * 100) : 0;
const asToMqRate = appSubmissions > 0 ? (questionnaires / appSubmissions * 100) : 0;
const overallConversionRate = clicks > 0 ? (questionnaires / clicks * 100) : 0;
// Update conversion rate displays
document.getElementById('clickToElRate').textContent = clickToElRate.toFixed(2) + '%';
document.getElementById('elToSlRate').textContent = elToSlRate.toFixed(2) + '%';
document.getElementById('slToAsRate').textContent = slToAsRate.toFixed(2) + '%';
document.getElementById('asToMqRate').textContent = asToMqRate.toFixed(2) + '%';
document.getElementById('overallConversion').textContent = overallConversionRate.toFixed(2) + '%';
// Update progress bar
document.getElementById('overallProgress').style.width = overallConversionRate + '%';
// Update dashboard conversion rates
document.getElementById('elConvRateDashboard').textContent = clickToElRate.toFixed(2) + '%';
document.getElementById('slConvRateDashboard').textContent = elToSlRate.toFixed(2) + '%';
document.getElementById('asConvRateDashboard').textContent = slToAsRate.toFixed(2) + '%';
document.getElementById('mqConvRateDashboard').textContent = asToMqRate.toFixed(2) + '%';
// Calculate cost per action metrics
const cpc = adSpend > 0 ? (adSpend / clicks) : 0;
const elCpl = elementorLeads > 0 ? (adSpend / elementorLeads) : 0;
const slCpl = steveLeads > 0 ? (adSpend / steveLeads) : 0;
const asCpa = appSubmissions > 0 ? (adSpend / appSubmissions) : 0;
const mqCpq = questionnaires > 0 ? (adSpend / questionnaires) : 0;
// Update cost per action displays
document.getElementById('cpcDashboard').textContent = '$' + cpc.toFixed(2);
document.getElementById('elCplDashboard').textContent = '$' + elCpl.toFixed(2);
document.getElementById('slCplDashboard').textContent = '$' + slCpl.toFixed(2);
document.getElementById('asCpaDashboard').textContent = '$' + asCpa.toFixed(2);
document.getElementById('mqCpqDashboard').textContent = '$' + mqCpq.toFixed(2);
// Update target comparison section
updateTargetComparisons();
}
// Update target vs actual comparisons
function updateTargetComparisons() {
// Get actual values
const actualClicks = parseInt(document.getElementById('clicks').value) || 0;
const actualElementorLeads = parseInt(document.getElementById('elementor_leads').value) || 0;
const actualSteveLeads = parseInt(document.getElementById('steve_leads').value) || 0;
const actualAppSubmissions = parseInt(document.getElementById('application_submissions').value) || 0;
const actualQuestionnaires = parseInt(document.getElementById('marketing_questionnaires').value) || 0;
// Calculate overall conversion rate
const actualClicksForConversion = actualClicks || 1; // Avoid division by zero
const actualConversionRate = (actualQuestionnaires / actualClicksForConversion * 100) || 0;
// Update actual values in target table
document.getElementById('actualClicks').textContent = actualClicks;
document.getElementById('actualElementorLeads').textContent = actualElementorLeads;
document.getElementById('actualSteveLeads').textContent = actualSteveLeads;
document.getElementById('actualAppSubmissions').textContent = actualAppSubmissions;
document.getElementById('actualQuestionnaires').textContent = actualQuestionnaires;
document.getElementById('actualConversionRate').textContent = actualConversionRate.toFixed(2) + '%';
// Get target values
const targetClicks = parseInt(document.getElementById('targetClicks').value) || 0;
const targetElementorLeads = parseInt(document.getElementById('targetElementorLeads').value) || 0;
const targetSteveLeads = parseInt(document.getElementById('targetSteveLeads').value) || 0;
const targetAppSubmissions = parseInt(document.getElementById('targetAppSubmissions').value) || 0;
const targetQuestionnaires = parseInt(document.getElementById('targetQuestionnaires').value) || 0;
const targetConversionRate = parseInt(document.getElementById('targetConversionRate').value) || 0;
// Update status indicators
updateStatusIndicator('clickStatus', actualClicks, targetClicks);
updateStatusIndicator('elementorLeadStatus', actualElementorLeads, targetElementorLeads);
updateStatusIndicator('steveLeadStatus', actualSteveLeads, targetSteveLeads);
updateStatusIndicator('appSubmissionStatus', actualAppSubmissions, targetAppSubmissions);
updateStatusIndicator('questionnaireStatus', actualQuestionnaires, targetQuestionnaires);
updateStatusIndicator('conversionRateStatus', actualConversionRate, targetConversionRate);
}
// Helper function to update status indicators
function updateStatusIndicator(elementId, actual, target) {
const element = document.getElementById(elementId);
if (target <= 0) {
element.textContent = '-';
element.className = 'px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800';
return;
}
if (actual >= target) {
element.textContent = 'On Target';
element.className = 'px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800';
} else {
element.textContent = 'Below Target';
element.className = 'px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800';
}
}
// Export to CSV
document.getElementById('exportBtn').addEventListener('click', function() {
// Get all data
const clicks = parseInt(document.getElementById('clicks').value) || 0;
const elementorLeads = parseInt(document.getElementById('elementor_leads').value) || 0;
const steveLeads = parseInt(document.getElementById('steve_leads').value) || 0;
const appSubmissions = parseInt(document.getElementById('application_submissions').value) || 0;
const questionnaires = parseInt(document.getElementById('marketing_questionnaires').value) || 0;
const adSpend = parseFloat(document.getElementById('ad_spend').value) || 0;
// Calculate conversion rates
const clickToElRate = clicks > 0 ? (elementorLeads / clicks * 100) : 0;
const elToSlRate = elementorLeads > 0 ? (steveLeads / elementorLeads * 100) : 0;
const slToAsRate = steveLeads > 0 ? (appSubmissions / steveLeads * 100) : 0;
const asToMqRate = appSubmissions > 0 ? (questionnaires / appSubmissions * 100) : 0;
const overallConversionRate = clicks > 0 ? (questionnaires / clicks * 100) : 0;
// Calculate cost per action metrics
const cpc = adSpend > 0 ? (adSpend / clicks) : 0;
const elCpl = elementorLeads > 0 ? (adSpend / elementorLeads) : 0;
const slCpl = steveLeads > 0 ? (adSpend / steveLeads) : 0;
const asCpa = appSubmissions > 0 ? (adSpend / appSubmissions) : 0;
const mqCpq = questionnaires > 0 ? (adSpend / questionnaires) : 0;
// Create CSV content
let csvContent = "Metric,Value,Rate,Cost\n";
csvContent += `Clicks,${clicks},,\n`;
csvContent += `Elementor Leads,${elementorLeads},${clickToElRate.toFixed(2)}%,$${elCpl.toFixed(2)}\n`;
csvContent += `Steve Leads,${steveLeads},${elToSlRate.toFixed(2)}%,$${slCpl.toFixed(2)}\n`;
csvContent += `App Submissions,${appSubmissions},${slToAsRate.toFixed(2)}%,$${asCpa.toFixed(2)}\n`;
csvContent += `Questionnaires,${questionnaires},${asToMqRate.toFixed(2)}%,$${mqCpq.toFixed(2)}\n`;
csvContent += `Overall Conversion Rate,,${overallConversionRate.toFixed(2)}%,\n`;
csvContent += `Total Ad Spend,$${adSpend.toFixed(2)},,\n`;
// Create download link
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('download', 'marketing_funnel_data.csv');
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
// Send to Webhook
document.getElementById('webhookBtn').addEventListener('click', function() {
// Get all data
const clicks = parseInt(document.getElementById('clicks').value) || 0;
const elementorLeads = parseInt(document.getElementById('elementor_leads').value) || 0;
const steveLeads = parseInt(document.getElementById('steve_leads').value) || 0;
const appSubmissions = parseInt(document.getElementById('application_submissions').value) || 0;
const questionnaires = parseInt(document.getElementById('marketing_questionnaires').value) || 0;
const adSpend = parseFloat(document.getElementById('ad_spend').value) || 0;
// Calculate conversion rates
const clickToElRate = clicks > 0 ? (elementorLeads / clicks * 100) : 0;
const elToSlRate = elementorLeads > 0 ? (steveLeads / elementorLeads * 100) : 0;
const slToAsRate = steveLeads > 0 ? (appSubmissions / steveLeads * 100) : 0;
const asToMqRate = appSubmissions > 0 ? (questionnaires / appSubmissions * 100) : 0;
const overallConversionRate = clicks > 0 ? (questionnaires / clicks * 100) : 0;
// Calculate cost per action metrics
const cpc = adSpend > 0 ? (adSpend / clicks) : 0;
const elCpl = elementorLeads > 0 ? (adSpend / elementorLeads) : 0;
const slCpl = steveLeads > 0 ? (adSpend / steveLeads) : 0;
const asCpa = appSubmissions > 0 ? (adSpend / appSubmissions) : 0;
const mqCpq = questionnaires > 0 ? (adSpend / questionnaires) : 0;
// Create JSON payload
const payload = {
timestamp: new Date().toISOString(),
metrics: {
clicks: clicks,
elementor_leads: elementorLeads,
steve_leads: steveLeads,
application_submissions: appSubmissions,
marketing_questionnaires: questionnaires,
ad_spend: adSpend
},
conversion_rates: {
click_to_elementor: clickToElRate,
elementor_to_steve: elToSlRate,
steve_to_application: slToAsRate,
application_to_questionnaire: asToMqRate,
overall_conversion: overallConversionRate
},
cost_per_action: {
cost_per_click: cpc,
cost_per_elementor_lead: elCpl,
cost_per_steve_lead: slCpl,
cost_per_application: asCpa,
cost_per_questionnaire: mqCpq
}
};
// In a real implementation, you would send this to your webhook URL
// For this demo, we'll just show an alert with the payload
alert('This would send the following data to your webhook:\n\n' +
'Webhook URL: https://your-webhook-url.com/api\n\n' +
'Payload:\n' + JSON.stringify(payload, null, 2));
// Actual fetch would look something like this:
/*
fetch('https://your-webhook-url.com/api', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => {
alert('Data successfully sent to webhook!');
})
.catch((error) => {
alert('Error sending data to webhook: ' + error);
});
*/
});
// Initialize calculations
updateCalculations();
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=chargesflow/funnel" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |