.toLowerCase();
const href = element.href ? element.href.toLowerCase() : '';
if (text.includes('whatsapp') || href.includes('wa.html')) {
return 'whatsapp';
}
if (text.includes('contact us') || text.includes('contact')) {
return 'contact_us';
}
if (text.includes('inquiry') || text.includes('enquiry')) {
return 'inquiry';
}
if (text.includes('call') || href.startsWith('tel:')) {
return 'call';
}
// 4. Fallback to a generic link type if it's a link but no specific type was found.
if (element.tagName === 'A' && element.closest('nav')) {
return 'nav_link';
}
if (element.tagName === 'A' && element.closest('footer')) {
return 'footer_link';
}
// 5. Default to 'other' if no match is found.
return 'other';
}
// --- Event Listener ---
document.addEventListener('click', (event) => {
// Find the closest link, button, or an element with a data-click-type.
const targetElement = event.target.closest('a, button, [data-click-type]');
if (targetElement) {
const clickData = {
domain_name: COMPANY_DOMAIN,
page_path: window.location.pathname,
click_type: getClickType(targetElement),
element_text: targetElement.textContent.trim() || targetElement.innerText.trim() || targetElement.href || targetElement.id || 'N/A'
};
// Send the data to your API.
sendClickData(clickData);
}
});
})();
Acrylic Laser Cutting Services
- home
- Acrylic Laser Cutting Services