The widget emits a stream of lifecycle events during a call. You can consume them in three places:Documentation Index
Fetch the complete documentation index at: https://docs.apifycloud.io/llms.txt
Use this file to discover all available pages before exploring further.
- Parent page — via
postMessagefrom the iframe (see Embedding) - Custom code — via
window.c2c.on(name, handler)inside injected scripts (see Custom code) - Integrations — forwarded server-side to your webhooks (see Integrations)
Common payload shape
Every event carries a common envelope:The
context object is the URL context you passed to the widget (see
Embedding — URL context).
It’s attached to every event so downstream systems always have
correlation data like orderId or customerTier.Event catalogue
widget_loaded
Fired once, when the widget finishes initial render. Useful to verify
the widget is actually present on pages where it should be, or to fire
a pageview-equivalent in analytics.
isPreview—truewhen rendered inside the Call Studio preview,falsein production.
call_started
Fired when the user taps the call button and the outbound call request
has been accepted.
destinationId— the profile the call is routed to, ornullfor the default profile.routingKey— routing key supplied via the session, if any.hasFormValues—trueif the pre-call form was used.
call_ended
Fired when the call is terminated cleanly — either the visitor tapped
hang-up or the agent (or IVR / queue) hung up. This is the most
important event for most integrations.
If the call fails because of a network or media issue, you get
call_error instead — call_ended is not emitted on
error paths.
duration— call length in seconds. Measured from the moment the visitor started the call.reason— one of:
| Value | Meaning |
|---|---|
user_hangup | The visitor tapped hang-up |
remote_hangup | The agent, IVR, or queue ended the call |
call_error
Fired when the call fails to start, or when it drops mid-call because
of a media failure. A spike in these events is your early warning
sign that something is wrong on the infrastructure or network side.
errorCode— machine-readable label. Currently one of:media_failed— the WebRTC media connection dropped- other codes may surface depending on the failure path; always
check
errorMessagefor details.
errorMessage— human-readable description.
survey_submitted
Fired when the visitor completes the post-call survey.
rating— average rating across the visitor’s answers (1–5).answerCount— how many survey questions the visitor answered.hasComment— whether the visitor added free-text feedback.
custom_button_clicked
Fired when the visitor interacts with a custom button you added in
Call Studio.
label— the label configured on the button in Call Studio.action— the action type configured (e.g.link,copy, etc.).
State transitions
The widget has a finite state machine:| From → to | Triggers event |
|---|---|
idle → calling | call_started |
calling → ended | call_ended |
calling → error | call_error |
ended → survey | (transition only, no event) |
survey → survey_submitted | survey_submitted |
Forwarding to your server
Every event above can be forwarded to your webhook endpoints through Integrations. UnlikepostMessage or window.c2c.on (both
client-only), integrations are delivered server-side with retries and
a circuit breaker.
See Integrations for setup.
What’s next
Custom code
Listen for these events from your own injected scripts.
Integrations
Forward events to your webhooks and servers.