Track any custom action on your website - from button clicks to purchases.
Use the global Trackveil.track() function to track custom events:
Trackveil.track(eventName, properties);
Parameters:
eventName (string, required) - Name of the eventproperties (object, optional) - Additional data about the event// Track CTA button click
document.querySelector('#cta-button').addEventListener('click', function() {
Trackveil.track('CTA Clicked', {
button_text: 'Start Free Trial',
location: 'hero'
});
});
// After successful form submission
Trackveil.track('Newsletter Signup', {
source: 'footer',
email_provided: true
});
// Track completed purchase
Trackveil.track('Purchase', {
value: 49.99,
currency: 'EUR',
product_id: '12345',
product_name: 'Premium Plan',
quantity: 1,
payment_method: 'stripe'
});
// Track video engagement
document.querySelector('video').addEventListener('play', function() {
Trackveil.track('Video Played', {
video_id: 'intro-video',
duration: 120,
title: 'Product Demo'
});
});
// Track PDF download
document.querySelector('a[href$=".pdf"]').addEventListener('click', function(e) {
Trackveil.track('File Downloaded', {
filename: e.target.getAttribute('href'),
type: 'PDF',
size: '2.4MB'
});
});
// E-commerce: add to cart
function addToCart(productId, price) {
Trackveil.track('Add to Cart', {
product_id: productId,
price: price,
currency: 'EUR'
});
}
// Contact form
document.querySelector('#contact-form').addEventListener('submit', function() {
Trackveil.track('Contact Form Submitted', {
form_name: 'Contact',
fields_filled: 5
});
});
// Track feature usage
Trackveil.track('Feature Used', {
feature_name: 'Dark Mode Toggle',
enabled: true
});
// Track internal search
Trackveil.track('Search', {
query: searchTerm,
results_count: results.length
});
// After successful signup
Trackveil.track('Account Created', {
plan: 'free',
method: 'email'
});
View all tracked events in your dashboard at /app/events. You'll see: