Virtue AI brings control, governance, and resilience to enterprise AI.
document.addEventListener('DOMContentLoaded', function () {
// Track any element that has data-cta="..."
var ctas = document.querySelectorAll('[data-cta]');
if (!ctas.length) return;
ctas.forEach(function (el) {
el.addEventListener('click', function (e) {
var ctaName = el.getAttribute('data-cta') || 'unknown';
var ctaText = (el.textContent || '').trim();
var href = (el.getAttribute('href') || '');
// Send GA4 event if gtag is available
if (window.gtag) {
gtag('event', 'cta_click', {
cta_name: ctaName,
cta_text: ctaText,
cta_url: href
});
}
// Optional: ensure the hit is sent before same-tab navigation.
// Only delay if it's a same-tab link (no target=_blank and has href)
var sameTab = !el.hasAttribute('target') && href && href.indexOf('#') !== 0;
if (sameTab) {
e.preventDefault();
// small delay; GA4 usually sends instantly, 120ms is plenty
setTimeout(function(){ window.location.href = href; }, 120);
}
});
});
});