Custom events
Bantico lets you send custom events to track the actions that matter to your product, campaign, or funnel.
Track method
Sends a Bantico custom_event from JavaScript.
bantico.track("custom_event", { customEventName: "signup", source: "footer",})Parameters
eventName
The Bantico event type. Use "custom_event" for user-defined events.
properties
Optional object containing the custom event name and any extra event properties.
Properties
customEventName
The custom event name, for example "signup", "demo_requested", or "roi_viewed".
[key]
Any additional custom properties for this event.
Data attributes
Track clicks declaratively with HTML data attributes. No extra JavaScript required.
Add data-bantico-event and data-bantico-custom-event-name to any clickable element such as a button or link:
<button data-bantico-event="custom_event" data-bantico-custom-event-name="signup"> Get Started</button>Adding properties
Add additional data-bantico-* attributes to include custom event properties:
<button data-bantico-event="custom_event" data-bantico-custom-event-name="signup" data-bantico-plan="Pro" data-bantico-source="hero"> Get Started</button>This sends a Bantico custom_event with customEventName: "signup" and properties { plan: "Pro", source: "hero" }.
Tracking forms
For form submissions, it's best to call bantico.track() inside your submit handler after validation succeeds. For example:
const handleSubmit = async (e) => { e.preventDefault() const result = await submitForm(data) if (!result.success) return bantico.track("custom_event", { customEventName: "signup", source: "footer", })}This ensures you only track successful submissions and avoids sending events for failed validation.