Hey @multimerce
I am not 100% sure about this, but Sometimes, the Klaviyo tracking script might take a moment to load, so firing the custom event right after the script loads may cause issues. A common fix is to wrap the event trigger in a setTimeout
or wait until the Klaviyo object is fully initialized.
<script async src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=MY_PUBLIC_API_KEY"></script>
<script>
window.onload = function() {
setTimeout(function() {
var klaviyo = window._learnq || [];
klaviyo.push(['track', 'Custom Event', {
}]);
}, 500);
};
</script>
although this is obvious - Replace MY_PUBLIC_API_KEY
with your actual public API key.
also Make sure the event data
is an object. If you’re including additional properties in the event, structure them like this:
{
'Property1': 'Value1',
'Property2': 'Value2',
}
I hope this helps and thank you for sharing your question here in the community.
Cheers
Arpit