funnel / index.html
chargesflow's picture
Add 3 files
7fc4ba3 verified
Raw History Blame Contribute Delete
35 kB
<!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>