The widget dispatches custom events that bubble from the host element, allowing you to integrate with analytics, tracking systems, or your existing JavaScript.Documentation Index
Fetch the complete documentation index at: https://docs.cadanapay.com/llms.txt
Use this file to discover all available pages before exploring further.
Event Reference
All events are dispatched on the widget’s host element and bubble up todocument. Use standard addEventListener() to listen for them.
| Event | Payload | When fired |
|---|---|---|
cdn-calculator:ready | { countries: Country[] } | Widget initialized and country data loaded |
cdn-calculator:calculate | { country, currency, gross, period } | User clicked calculate (before API request) |
cdn-calculator:result | Result | Calculation completed successfully |
cdn-calculator:view | { view: 'form' | 'result' } | User switched between form and result views |
cdn-calculator:error | ApiError | API request failed or validation error |
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.