Smart Click Fraud Detection for Affiliate Ads

Smart Click Fraud Detection Tool

Analyze affiliate ad clicks to identify and mitigate fraudulent activity.

Campaign Click Log

Fraud Detection Rules

Analysis Dashboard

-

Total Clicks

0

Flagged Clicks

0

Fraud Percentage

0%

Est. Loss

$0

Detailed Fraud Report

IP Address Timestamp Reason for Flag

${click.ip} @ ${new Date(click.timestamp).toLocaleTimeString()} (${click.country})

`).join(''); }; const handleDownloadPdf = () => { const pdfContentEl = document.getElementById('pdf-content'); if (!pdfContentEl) return; // Populate PDF document.getElementById('pdf-timestamp').textContent = new Date().toLocaleString('en-US'); const pdfRiskBadge = document.getElementById('pdf-risk-level-badge'); pdfRiskBadge.className = riskBadge.className; pdfRiskBadge.textContent = riskBadge.textContent; document.getElementById('pdf-summary-total').textContent = summaryTotal.textContent; document.getElementById('pdf-summary-flagged').textContent = summaryFlagged.textContent; document.getElementById('pdf-summary-percent').textContent = summaryPercent.textContent; document.getElementById('pdf-summary-loss').textContent = summaryLoss.textContent; const tableClone = document.querySelector('.overflow-x-auto table').cloneNode(true); const pdfTableContainer = document.getElementById('pdf-analysis-table-container'); pdfTableContainer.innerHTML = ''; pdfTableContainer.appendChild(tableClone); pdfContentEl.classList.remove('hidden'); html2canvas(pdfContentEl, { scale: 2 }).then(canvas => { pdfContentEl.classList.add('hidden'); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const margin = 40; const imgWidth = pdfWidth - (margin * 2); const imgHeight = (canvas.height * imgWidth) / canvas.width; pdf.addImage(imgData, 'PNG', margin, margin, imgWidth, imgHeight); pdf.save('click-fraud-report.pdf'); }).catch(err => { console.error("Error generating PDF:", err); pdfContentEl.classList.add('hidden'); }); }; const formatCurrency = (val) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(val); // --- Event Listeners --- addClickBtn.addEventListener('click', () => { // For simplicity, this adds a random click. A real tool might have a form. const ips = ['203.0.113.15', '198.51.100.22', '203.0.113.15', '192.0.2.88', '198.51.100.22', '203.0.113.15']; const countries = ['USA', 'USA', 'GBR', 'CAN', 'USA', 'USA'] const randomIp = ips[Math.floor(Math.random() * ips.length)]; const randomCountry = countries[Math.floor(Math.random() * countries.length)]; const newClick = { ip: randomIp, timestamp: new Date(Date.now() - Math.random() * 60000).toISOString(), country: randomCountry, }; addClick(newClick); }); [ipThresholdInput, clickValueInput, targetCountrySelect].forEach(input => { input.addEventListener('input', analyzeAndRender); }); pdfBtn.addEventListener('click', handleDownloadPdf); // --- Initial Load --- const sampleData = [ { ip: '72.229.28.185', timestamp: new Date(Date.now() - 55000).toISOString(), country: 'USA' }, { ip: '216.58.194.174', timestamp: new Date(Date.now() - 50000).toISOString(), country: 'USA' }, { ip: '45.33.32.156', timestamp: new Date(Date.now() - 45000).toISOString(), country: 'CAN' }, // Mismatch { ip: '72.229.28.185', timestamp: new Date(Date.now() - 40000).toISOString(), country: 'USA' }, { ip: '72.229.28.185', timestamp: new Date(Date.now() - 38000).toISOString(), country: 'USA' }, { ip: '72.229.28.185', timestamp: new Date(Date.now() - 37000).toISOString(), country: 'USA' }, { ip: '72.229.28.185', timestamp: new Date(Date.now() - 36500).toISOString(), country: 'USA' }, { ip: '72.229.28.185', timestamp: new Date(Date.now() - 36000).toISOString(), country: 'USA' }, // Flood { ip: '104.244.42.1', timestamp: new Date(Date.now() - 20000).toISOString(), country: 'USA' }, ]; sampleData.forEach(c => addClick(c)); });
Scroll to Top