// Ensure HubSpot tracking script is loaded (optional)
(function(d,s,i,r) {
if (d.getElementById(i)){return;}
var n=d.createElement(s),e=d.getElementsByTagName(s)[0];
n.id=i;n.src='//js.hs-scripts.com/378546.js';
e.parentNode.insertBefore(n, e);
})(document, "script", "hs-script-loader");
// Event listener for the custom JS events named "ceros-analytics-event"
document.body.addEventListener('ceros-analytics-event', function(event) {
// Conditions under which the event will fire to HubSpot
if (event.detail.eventType === 'component-click') {
console.log('Component click detected:', event.detail.componentName);
// Push a normal event to HubSpot, using the name of the Ceros element as the event ID.
if (typeof _hsq !== 'undefined') {
console.log('Pushing event to HubSpot:', event.detail.componentName);
_hsq.push([
"trackEvent",
{
id: event.detail.componentName
}
]);
}
// Optional error handling
else {
console.error("HubSpot tracking is not initialized");
}
}
});