Events Overview
Communication between the Element and your app can be handled either by PostMessage communication or via HTTP redirects.
Listening to Events
We strongly recommend using one of the Element SDKs to make listening to events easy. They provide you with callback functions that are invoked every time a specific type of event occurs (such as open
, success
, exit
, etc).
Each type of Element will emit its own events. See General Events and Element Specific Events for more information about the events that are emitted.
PostMessage without SDK
To recieve events via PostMessage, pass the query parameter event_channel=message
to the Elements url. For example:
To listen to the emitted events, add an event listener onto the window object:
Redirects
Redirects are the default way of listening to element events if you are not using one of the SDKs. Your webview / app should intercept the redirects in order to react accordingly to state changes. All redirect URLs will have the scheme (“prefix”) methodelements
. The event source will be the URL host and the payload will be query strings.
HTTP redirects from Method Elements are in the following format: