CTA Optimization Tool

CTA Optimization Tool

Generate and analyze high-impact Call-to-Action text with AI.

CTA Details

Generated CTA Variations

Your AI-generated CTA ideas will appear here.

Rationale: ${cta.rationale}

`).join(''); } // --- UTILITY FUNCTIONS --- function showNotification(message) { notification.textContent = message; notification.classList.remove('opacity-0'); setTimeout(() => notification.classList.add('opacity-0'), 2000); } function copyToClipboard(text, message) { navigator.clipboard.writeText(text).then(() => showNotification(message)); } // --- PDF GENERATION --- async function generatePdfReport() { if (generatedCtas.length === 0) { showNotification("No CTAs to export."); return; } downloadPdfBtn.disabled = true; downloadPdfBtn.textContent = '...'; const ctaCards = generatedCtas.map(cta => `
${cta.text}

Rationale: ${cta.rationale}

`).join(''); const reportHtml = `

Conversion Strategy Brief

For CTA: ${inputsData.ctaText}

Campaign Goal & Audience

Goal: ${inputsData.goal}
Audience: ${inputsData.context}

Generated CTA Variations
${ctaCards}
`; const pdfTemplate = document.getElementById('pdf-template'); pdfTemplate.innerHTML = reportHtml; pdfTemplate.classList.remove('invisible'); try { const { jsPDF } = window.jspdf; const canvas = await html2canvas(pdfTemplate.querySelector('.pdf-page'), { scale: 2 }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(), pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save(`CTA_Variations_${inputsData.ctaText.replace(/\s+/g, '_')}.pdf`); } catch (e) { console.error('PDF Generation Error:', e); } finally { downloadPdfBtn.disabled = false; downloadPdfBtn.textContent = 'Download PDF'; pdfTemplate.classList.add('invisible'); pdfTemplate.innerHTML = ''; } } // --- EVENT LISTENERS --- generateBtn.addEventListener('click', generateCtas); resultsContainer.addEventListener('click', (e) => { if (e.target.classList.contains('copy-cta-btn')) { const text = generatedCtas[e.target.dataset.index].text; copyToClipboard(text, 'CTA copied!'); } }); downloadPdfBtn.addEventListener('click', generatePdfReport); });
Scroll to Top