Customer Advocacy Dashboard

Customer Advocacy Dashboard

Overall Advocacy Summary

Total Advocates

0

Average NPS

0

Total Referrals ($)

$0

Total Testimonials

0

NPS Distribution

Advocacy Type Breakdown

Testimonial Sentiment

Detailed Advocacy Records

ID Customer Name NPS Score Advocacy Type Date Referral Value ($) Sentiment Notes

${totalReferralValueElem.textContent}

Total Testimonials

${totalTestimonialsCountElem.textContent}

`; pdfContentWrapper.appendChild(summarySection); // Add distribution charts const chartsSection = document.createElement('div'); chartsSection.classList.add('grid', 'grid-cols-2', 'gap-6', 'mb-6'); chartsSection.innerHTML = `

NPS Distribution

Advocacy Type Breakdown

Testimonial Sentiment

`; pdfContentWrapper.appendChild(chartsSection); // Populate PDF charts (re-use logic but target PDF elements) const totalRecords = customerAdvocacyRecords.length; const npsCategoryCounts = { 'Promoter': 0, 'Passive': 0, 'Detractor': 0 }; customerAdvocacyRecords.forEach(record => { const category = getNPSCategory(record.npsScore); npsCategoryCounts[category]++; }); renderBarChart(chartsSection.querySelector('#pdfNpsDistributionChart'), npsCategoryCounts, 'nps'); const advocacyTypeCounts = customerAdvocacyRecords.reduce((acc, record) => { acc[record.advocacyType] = (acc[record.advocacyType] || 0) + 1; return acc; }, {}); renderBarChart(chartsSection.querySelector('#pdfAdvocacyTypeChart'), advocacyTypeCounts, 'count'); const testimonialSentimentCounts = customerAdvocacyRecords .filter(record => ['Testimonial', 'Review', 'Social Mention'].includes(record.advocacyType) && record.sentiment !== 'N/A') .reduce((acc, record) => { acc[record.sentiment] = (acc[record.sentiment] || 0) + 1; return acc; }, {}); renderBarChart(chartsSection.querySelector('#pdfTestimonialSentimentChart'), testimonialSentimentCounts, 'count'); // Add detailed advocacy list table const advocacyListSection = document.createElement('div'); advocacyListSection.innerHTML = `

Detailed Advocacy Records

${dashboardAdvocacyTableBody.innerHTML}
ID Customer Name NPS Score Advocacy Type Date Referral Value ($) Sentiment Notes
`; pdfContentWrapper.appendChild(advocacyListSection); // Options for html2pdf const options = { margin: 10, filename: 'Customer_Advocacy_Dashboard.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, logging: true, dpi: 192, letterRendering: true }, jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }, pagebreak: { mode: ['avoid-all', 'css', 'legacy'] } }; // Generate PDF from the temporary content wrapper html2pdf().from(pdfContentWrapper).set(options).save(); // Clean up the temporary div (optional, as it's not appended to the DOM) pdfContentWrapper.remove(); } /** * Loads initial sample data for the dashboard. * Relevant to USA context. */ function loadSampleData() { customerAdvocacyRecords = [ { id: 'CA001', customerName: 'John Smith', npsScore: 9, advocacyType: 'Referral', date: '2024-06-01', referralValue: 1000, sentiment: 'Positive', notes: 'Referred new client ABC Corp' }, { id: 'CA002', customerName: 'Jane Doe', npsScore: 7, advocacyType: 'Testimonial', date: '2024-06-05', referralValue: 0, sentiment: 'Neutral', notes: 'Provided a written testimonial' }, { id: 'CA003', customerName: 'Peter Jones', npsScore: 4, advocacyType: 'Review', date: '2024-06-10', referralValue: 0, sentiment: 'Negative', notes: 'Left a 2-star review on G2' }, { id: 'CA004', customerName: 'Sarah Lee', npsScore: 10, advocacyType: 'Social Mention', date: '2024-06-12', referralValue: 0, sentiment: 'Positive', notes: 'Positive tweet about product launch' }, { id: 'CA005', customerName: 'Mike Brown', npsScore: 8, advocacyType: 'Referral', date: '2024-06-15', referralValue: 500, sentiment: 'Positive', notes: 'Referred two small businesses' }, { id: 'CA006', customerName: 'Emily White', npsScore: 6, advocacyType: 'Testimonial', date: '2024-06-18', referralValue: 0, sentiment: 'Neutral', notes: 'Provided video testimonial' }, { id: 'CA007', customerName: 'David Green', npsScore: 10, advocacyType: 'Case Study', date: '2024-06-20', referralValue: 0, sentiment: 'Positive', notes: 'Participated in a successful case study' }, { id: 'CA008', customerName: 'Olivia Black', npsScore: 2, advocacyType: 'Review', date: '2024-06-22', referralValue: 0, sentiment: 'Negative', notes: 'Left a critical review on Yelp' } ]; }
Scroll to Top