---
title: Set up widget analytics
slug: set-up-widget-analytics
icon: 📈
docTags: 
createdAt: 2024-02-23T00:21:13.558Z
---

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 ](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage)method to share event data with the parent page. Below is an example of the event:

```javascript
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.

```javascript
window.addEventListener(
  "message",
  (event) => {
     if (event.origin !== "https://acme.findahelpline.com") return;
     if (event.data.event === 'widget-click-to-call') {
        // Add your code…
     }
  },
  false
);
```

