BlogCRM and integrations

GA4 and Yandex Metrica: Turning a Chatbot Conversation Action Into an Analytics Goal

A customer left their phone number inside a bot, not on your site – and GA4 and Metrica never saw it. Here's how to carry that action through to an analytics goal.

Ad campaigns are tagged, GA4 and Yandex Metrica both show the traffic arriving on your site. Then a visitor clicks "Message us on Telegram" or "Chat on WhatsApp" and leaves the page for a messaging app. That's where they actually hand over a phone number, confirm a booking, or pay an invoice. None of that shows up in your analytics: the tools logged a click on a button, not what happened inside the conversation that followed. Here's how to carry a specific chatbot action through to a goal in GA4 and Yandex Metrica, where you can set this up yourselves, and where it genuinely needs a developer.

Why a bot conversation never reaches your reports

GA4 and Yandex Metrica both count events through a script running in the browser on your page. As long as a visitor stays on that page, the script can see clicks, scrolling, form submissions. The moment someone taps through to Telegram or WhatsApp, that browser tab is left behind – the rest of the exchange happens in a separate app that neither tracking script is attached to. So analytics records exactly one thing: "a visitor clicked the bot link." It has no way of knowing whether that person went on to leave a phone number, confirm a booking, or simply closed the chat.

Two different situations, two different fixes

Before configuring anything, it's worth separating two cases, because they're solved differently.

The first: the conversation stays inside a widget on your own page, the way it does in our case on an AI assistant running on a Tilda site. The browser tab never closes, so GA4 and Metrica's scripts keep running, and you can fire an event the instant the widget reports the action you care about.

The second: the visitor leaves for Telegram or WhatsApp – a separate app outside the browser entirely. Here the page's script can no longer see anything, so the goal has to be closed from the server, after the action has actually happened inside the bot.

When the conversation never leaves your site

This is the easy case. The moment the widget on your page registers the action you care about – a visitor left a phone number inside the chat form, tapped "confirm booking" – you can fire the Yandex Metrica goal with reachGoal and the GA4 event with gtag, right from the visitor's browser, in the same instant. Technically this is no different from a goal on a regular form submission; the only change is that the "form" now lives inside a chat widget instead of a separate block on the page. Whoever installed the widget just needs to wire those two function calls to fire once, at the moment the widget reports success.

When the visitor leaves for Telegram or WhatsApp

This is harder: you need to carry a visitor identifier across the handoff into the messaging app, so that later, when the qualifying action happens inside the bot, you can send the event back under the name of that same visitor.

Before showing the link to the bot, your site's script grabs two identifiers: the Yandex Metrica ClientID (returned by the counter's getClientID method) and the GA4 client_id, which lives in the browser's _ga cookie. For Telegram, passing these along is straightforward: a bot link supports a ?start= parameter where both identifiers can be packed in. When someone opens the bot through that link, the bot's backend receives this parameter together with the first message and stores it against the lead.

WhatsApp is trickier: a wa.me link has no hidden parameter, only a visible pre-filled text field. If a short identifier doesn't get in the way of the conversation, you can encode it into that text – but it's far less reliable than Telegram's start parameter, and breaks easily if the visitor edits the pre-filled text before sending.

How the goal gets closed on the server side

When the qualifying action happens inside the bot – the AI agent captured a phone number, a visitor confirmed a booking, a payment went through – the bot's server sends the event to both systems using the identifiers it saved earlier:

  • to GA4, via the Measurement Protocol: a request carrying your stream's measurement ID, an API secret, and the stored client_id; the event itself gets marked as a conversion in GA4's settings;
  • to Yandex Metrica, as an offline conversion: you enable offline conversion tracking once in the counter's settings, then upload rows via the API containing the ClientID, the goal identifier, and the event's timestamp.

Here's how that splits between what gets automated and what a person still has to decide:

StepWhat the code and AI agent doWhat a person decides
Visitor opens the bot link from your siteSite script appends ClientID and client_id to the linkA developer sets up the link generation once
Bot runs the conversation and captures a phone number or confirmationThe agent identifies the qualifying moment and prepares the event dataThe business owner decides which action actually counts as the goal
The event is sent to GA4 and MetricaThe server builds and sends requests to both APIsA developer checks the event arrived and wasn't duplicated
Data shows up in reportsAnalytics counts conversions on its ownMarketing evaluates campaigns on the real action, not the click to the bot

Which actions are worth tracking as a goal

It's tempting to set up a goal on "started a conversation with the bot." That's a noisy metric – it grows with every click, including accidental ones, and tells you nothing about traffic quality. It's more useful to pick a moment that already matters to the business on its own terms: a phone number was captured, a booking was confirmed, a payment went through. That moment usually matches the rule that decides when your agent creates a lead in the CRM in the first place – covered in detail in amoCRM and AI: How an Agent Creates Leads, Moves Pipeline Stages. In our SAYF DESIGN case study, the lead in amoCRM is created at the exact moment a phone number appears in the conversation – that's the same point worth sending to analytics as a goal, without building a separate piece of logic for it.

Common mistakes and honest limitations

A few things worth checking before launch:

  • Metrica's ClientID and GA4's client_id are two different identifiers – easy to swap by mistake when passing them through a link parameter.
  • Never send a phone number, name, or email as an event parameter – neither GA4 nor Metrica is built to store personal data in the clear; send only the fact of the action and its identifiers.
  • Offline conversions in Metrica aren't processed instantly – don't expect the goal to appear in the report the minute a visitor leaves a phone number in the bot.
  • If a browser blocks cookies or someone opens your site in private mode, the ClientID and client_id never get captured, and there's nothing to link the bot action to a specific site visit. That's an architectural limit, not a misconfiguration you can work around.

If the first contact with a customer starts from a phone call driven by advertising rather than a site visit, a different attribution mechanism applies – covered in Call Tracking: How to Link a Phone Call to Its Ad Source. For the general mechanics of how your site, bot, and CRM pass events to each other, see Webhooks in Plain English.

FAQ

Can this be set up without a developer?

No. You need at least one developer to wire up passing identifiers into the bot link and sending events from the server to GA4 and Metrica. Once it's set up, it runs on its own without manual steps.

What if the bot only lives on Telegram and no one visits the website?

Then there's no browser ClientID or client_id to carry over in the first place – the whole chain starts on the site. In that setup, you'd need a different way to identify the traffic source, such as separate bot links for different ad campaigns, but you won't be able to tie a specific site visit to a specific action inside the bot.

How quickly does the goal show up in reports?

An event sent via GA4's Measurement Protocol usually appears in reports within a day. Yandex Metrica processes offline conversions through a separate import cycle and doesn't show them immediately – build in a delay and avoid drawing conclusions from the last hour of data.

Yes, the same as for any other analytics collection on your site: your privacy policy should disclose that action data is sent to GA4 and Yandex Metrica, and the event itself must never contain a visitor's personal data.

What if a customer messages from their phone first, then visits the site later from a desktop?

Those are two separate visits with two separate identifiers, and analytics has no way to merge them on its own. If treating that customer as one person matters to the business, that's a job for your CRM's lead-matching rules, not for GA4 or Metrica.

More on how your site, bot, and ad accounts pass data to each other is in the Integrations section. If you'd like to work through your own goals-and-analytics setup with real numbers, that's a conversation worth starting on our contact page.

After the article

Want this in your business?

Describe your task in the brief and we’ll reply with where you should start. The first meeting takes 30 minutes.

Or message me directly:WhatsApp ↗Telegram ↗

Meeting brief

Monthly marketing budget
Where to reach you
When works for you? (optional)

We’ll confirm the exact time by message.