Set up widget analytics
2 min
ThroughLine analytics in the widget are recorded using Matomo Tag Manager (MTM). However, you can work with your development team to capture events being generated by the widget in the containing page and send them to your measurement solution.
What events are available?
ThroughLine utilizes the Window:postMessage method to share event data with the parent page. Below is an example of the event:
window.parent.postMessage(
JSON.stringify({ event: 'widget-click-to-call' }), '*'
);The following event types are available:
- widget-click-to-call
- widget-click-to-emergency-services
- widget-click-to-helpline-website
- widget-click-to-online-chat
- widget-click-to-reporting-form
- widget-click-to-sms
- widget-click-to-tty
- widget-click-to-whatsapp
How might you capture the analytics events?
Add this JavaScript snippet to capture analytics events and push them to your measure solution.
window.addEventListener(
"message",
(event) => {
if (event.origin !== "https://acme.findahelpline.com") return;
if (event.data.event === 'widget-click-to-call') {
// Add your codeβ¦
}
},
false
);