6️⃣Setup in-app custom events
Custom events are user-defined interactions or actions that you want to track specifically for your website or application.
What are custom events?
Key components of custom events
Attribute
Description
Example
How to track custom events with the Cookie3 Analytics snippet?
// Example implementation for tracking button clicks
document.addEventListener('DOMContentLoaded', function() {
// Select all buttons with the class 'track-click'
var buttons = document.querySelectorAll('.track-click');
buttons.forEach(function(button) {
button.addEventListener('click', function() {
// Get button text or a data attribute for the name
var buttonName = this.textContent || this.getAttribute('data-name');
// Track the event
window.cookie3.trackEvent(
{
category: 'Button Click', // Category
action: 'Click', // Action
name: buttonName, // Name (optional)
value: 1 // Value (optional)
}
);
});
});
});Example Event Configurations
Tracking Call To Action Clicks
Tracking User Reviews
Last updated