Custom Integrations ​
When the Parent Window
integration is enabled for a Videobot, it sends events to the parent page using iframe messages. To learn more about how they work, see this guide on MDN.
This allows the parent page to listen to analytics events and forward them to any third party analytics platform.
Setting Up ​
First, the Parent Window
integration should be enabled for the Videobot. It can be found from the dashboard, within the Videobot Settings
tab, under the Tracking & analytics
heading.
After the feature is enabled, the Videobot will start sending analytics events via iframe messages. To forward these messages to the data layer, the following script can be used:
<script>
window.addEventListener('message', function(event) {
if (event.origin !== 'https://videobot.com') {
return
}
if (event.data.action !== 'VIDEOBOT_ANALYTICS_EVENT') {
return
}
window.dataLayer.push(
Object.assign({ event: event.data.eventName }, event.data.data)
)
})
</script>
The above script does the following:
- Listens to all iframe
postMessage
events - Ensures they come from the Videobot domain
- Filters to events related to analytics
- Sends the event to the Google Analytics data layer
Further Reading ​
To understand what types of events will be sent by Videobot, refer to the Supported Events article.