Track widget leads in your analytics tools
Listen to the botello:lead event to count contacts left in the chat in GA4, Google Tag Manager or Meta Pixel.
- Plans
- All plans
- Channels
- Website
The chat lives in an iframe: your analytics tools cannot see what happens inside it. So that you can still count the contacts generated by the assistant, the widget dispatches the botello:lead event on your page every time a visitor leaves their contact details. You then forward it to Google Analytics 4, Google Tag Manager, Meta Pixel or any other tool.
Measuring the number of leads coming from the chat, using them as a conversion goal, optimizing an ad campaign on these leads.
Before you start
- The widget is installed on your site: see Install the chatbot on your website.
- Your analytics tool is already installed on the same pages (GA4 tag, GTM container or Meta Pixel).
- You respect the visitor’s cookie choice: only send the event to an advertising tool if the visitor has accepted it.
The event
| Property | Value |
|---|---|
| Name | botello:lead |
| Target | Your page’s window |
| Type | CustomEvent |
| Data | event.detail.source: gate, handoff, chat or widget |
| Personal data | None: no name, no e-mail, no message |
Values of source:
source | When |
|---|---|
gate | The visitor filled in the form required before chatting |
handoff | The visitor submitted the contact-the-team form (excluding order tracking) |
chat | The assistant took the contact request in the conversation and passed it on to the team |
widget | Fallback value for any other source added later |
Only Botello’s iframe can dispatch the event. It fires when the contact is saved, once per contact.
Connect your tool
Choose the tool
Use the tab below for the tool already on your site. With Google Tag Manager, you only need to add a small script; the rest is configured in GTM.
Add the listener
Paste the script after your analytics tool’s tag, on every page where the widget is installed. It can be before or after the Botello tag.
<script>
window.addEventListener('botello:lead', function (event) {
if (typeof gtag !== 'function') return;
// "generate_lead" is a GA4 recommended event.
gtag('event', 'generate_lead', {
lead_source: 'botello_' + event.detail.source, // botello_gate, botello_handoff, botello_chat
});
});
</script>In GA4, then mark generate_lead as a key event (AdminEvents). To analyze lead_source, create an event-scoped custom dimension on that parameter.
Check
Open your site, then your platform’s testing tool (GA4 DebugView, GTM Preview mode, Meta Pixel Helper). In the chat, leave your contact details, for example by asking to talk to the team. The event should appear within seconds.
To test without any tool, type this in your browser console:
window.addEventListener('botello:lead', (e) => console.log('botello:lead', e.detail));Examples
Send a conversion event without personal data, with source as the only detail. To link a lead to a person, use the lead.created webhook on the server side.
Try to grab the visitor’s e-mail from the page to send it to an advertising tool: the event deliberately does not contain it.
Troubleshooting
| What you see | Likely cause | Fix |
|---|---|---|
| No event | The listener is on document instead of window | Listen on window |
| No event after the order-tracking form | That form does not create a lead | Expected |
gtag is not defined or fbq is not defined | The script is placed before the tool’s tag, or the tool is blocked by consent | Place the listener after the tool’s tag. The typeof … !== 'function' check prevents the error |
| The event shows in GTM but not in GA4 | GA4 tag not published, or trigger misnamed | Check the exact name botello_lead, then publish the container |
| Fewer leads in the tool than in Botello | Ad blockers, cookies refused, leads from other channels (WhatsApp, Instagram) | Expected: the event only covers the widget on your site and depends on the visitor’s browser |