Skip to main content
The widget dispatches custom events that bubble from the host element, allowing you to integrate with analytics, tracking systems, or your existing JavaScript.

Event Reference

All events are dispatched on the widget’s host element and bubble up to document. Use standard addEventListener() to listen for them.

Event Details

cdn-calculator:ready

Fired when the widget is fully loaded and ready for user interaction.
JavaScript

cdn-calculator:calculate

Fired when user submits the form, before making the API request.
JavaScript

cdn-calculator:result

Fired when calculation completes successfully.
JavaScript

cdn-calculator:view

Fired when user navigates between form and result views.
JavaScript

cdn-calculator:error

Fired when an error occurs (invalid API key, network issues, etc.).
JavaScript

Integration Example

Google Analytics 4:
JavaScript

Event Payload Structures

cdn-calculator:ready

JavaScript

cdn-calculator:calculate

JavaScript

cdn-calculator:result

JavaScript

cdn-calculator:view

JavaScript

cdn-calculator:error

JavaScript
All monetary amounts are returned in cents to avoid floating-point precision issues. Divide by 100 to get the actual currency amount.