# Google Analytics events

> Which events the AI Sales Agent and AI Search send to your Google Analytics 4, and what each one means.

URL: https://help.yasan.ai/en/google-analytics-events/
Updated: 2026-11-12

If your website uses **Google Analytics 4 (GA4)**, the AI Sales Agent and AI Search send events to it **automatically**. They are sent only for visitors who agreed to analytics cookies (see [Cookie consent](#cookie-consent)). If GA4 runs through the Google tag (`gtag.js`), there is nothing else to set up. If you only use Google Tag Manager, see [Google Tag Manager](#google-tag-manager) below. Every event name starts with `yasan_`, so you can find them easily.

If your website has no Google Analytics, nothing is sent and both widgets work as usual.

## Google Tag Manager

If your website has Google Tag Manager but no Google tag (`gtag.js`), the widgets put the events into the Tag Manager data layer (`dataLayer`). Tag Manager passes them on to GA4 only once you tell it to:

1. Create a **Custom Event** trigger, set **Event name** to `^yasan_` and tick **Use regex matching**.
2. Create a **Google Analytics: GA4 Event** tag with your measurement ID, set **Event name** to `{{Event}}` and fire it on that trigger.
3. For each parameter you want in GA4 (for example `product_id` or `position`), create a **Data Layer Variable** of the same name and add it to the tag's event parameters.
4. Publish the container.

## Cookie consent

Consent is checked twice:

1. **The widgets send events only for visitors who agreed to analytics cookies.** The widget has to know the visitor's choice: on Shoptet and Shopify it reads it automatically from the platform's cookie banner (on Shopify, the one set up in your Shopify admin); on any platform it also reads Cookiebot, CookieYes and OneTrust; with another cookie bar, pass it to the widget with `window.Yasan.setConsent`, as described in [Setting up cookie consent](https://help.yasan.ai/en/cookie-consent-setup/). Until the widget knows that the visitor agreed, nothing is sent to Google Analytics.
2. **Google Analytics then applies its own Consent Mode**, just as for the rest of your website: in **advanced** Consent Mode, it only records anonymous, cookieless pings without consent; in **basic** Consent Mode, nothing is sent to Google until the visitor agrees.

## What we send, and what we don't

We **never** send the text of messages, search queries, e-mail addresses or any other personal details. The events only say what happened, plus details such as the product ID and name, the product's position in the list, or the number of products shown. The only text we send is a conversation starter the visitor clicked, which you wrote yourself, and the address of a link opened from a reply, without the part after `?`.

Every event carries the `yasan_widget` parameter: `chatbot` for the AI Sales Agent, `search` for AI Search.

## AI Sales Agent events

| Event | When it is sent | Parameters |
|---|---|---|
| `yasan_chatbot_loaded` | The chat widget loaded on the page | – |
| `yasan_chatbot_open` | The chat window opened | `open_trigger`: `manual` (the visitor clicked the chat button), `page_click` (the visitor clicked a button or link on your page that opens the chat), `host` (a script on your page opened it without the visitor clicking), `invitation` (the visitor clicked the intro bubble), `auto` (opens by itself), `operator` (an operator joined), `restored` (it was already open) |
| `yasan_chatbot_close` | The chat window closed | – |
| `yasan_chatbot_invitation_shown` | The intro bubble appeared | – |
| `yasan_chatbot_invitation_dismissed` | The visitor closed the intro bubble | – |
| `yasan_chatbot_starter_click` | The visitor clicked a conversation starter | `starter_question` (the starter's text, as you wrote it), `position` |
| `yasan_chatbot_message_sent` | The visitor sent a message | `is_first_message` |
| `yasan_chatbot_reply_received` | A reply arrived | `reply_type` (`assistant` or `operator`), `product_count`, `has_questions`, `handoff_offered`, `latency_ms` |
| `yasan_chatbot_product_view` | A recommended product appeared in the chat | `product_id`, `product_name` |
| `yasan_chatbot_product_click` | The visitor clicked a recommended product | `product_id`, `product_name`, `position` |
| `yasan_chatbot_link_click` | The visitor opened a link in a chat reply | `link_url` (the page's address without the part after `?`), `position` (which link in the reply) |
| `yasan_chatbot_add_to_cart` | A product was added to the cart from the chat | `product_id` |
| `yasan_chatbot_discount_copied` | The visitor copied a discount code | `product_id` |
| `yasan_chatbot_questions_answered` | The visitor answered the follow-up questions | `question_count` |
| `yasan_chatbot_questions_skipped` | The visitor skipped the follow-up questions | – |
| `yasan_chatbot_contact_form_open` | The form for contacting a person opened | `source` (`header` or `message`) |
| `yasan_chatbot_contact_submitted` | The visitor left their contact details | `live_chat_enabled` |
| `yasan_chatbot_email_verified` | The visitor confirmed their e-mail with a code | – |
| `yasan_chatbot_operator_joined` | An operator took over the conversation | – |
| `yasan_chatbot_conversation_reset` | The visitor started a new conversation | – |

## AI Search events

| Event | When it is sent | Parameters |
|---|---|---|
| `yasan_search_open` | The search window opened | `open_source`: `focus`, `click`, `submit`, `input`, `key` or `api` (how the visitor opened it; `api` is a search button on your site or your own script) |
| `yasan_search_close` | The search window closed | – |
| `yasan_search_focus_shelf_shown` | The product tips shown before typing appeared | – |
| `yasan_search_submitted` | A search was made | `trigger`: `submit` (Enter), `pause` (the visitor stopped typing), `handover` (from your own search box), `scope` (a filter changed), `retry` |
| `yasan_search_no_results` | Nothing matched the search | – |
| `yasan_search_answer_received` | The AI answer to a search arrived | `product_count`, `has_questions` |
| `yasan_search_product_click` | The visitor clicked a product | `product_id`, `surface`, `position`, `category_id` |
| `yasan_search_add_to_cart` | A product was added to the cart from the search | `product_id`, `surface`, `position` |
| `yasan_search_shelf_open` | The visitor opened a whole product row | `surface`, `category_id`, `position` |
| `yasan_search_load_more` | The visitor loaded more products | – |
| `yasan_search_filter_add` | The visitor added a filter | `filter_type`, `filter_key`, `surface` |
| `yasan_search_filter_remove` | The visitor removed a filter | `filter_type`, `filter_key`, `surface` |
| `yasan_search_question_answered` | The visitor answered a follow-up question | `surface`, `position` |
| `yasan_search_message_sent` | The visitor sent a message in the chat view | – |
| `yasan_search_reply_received` | A reply arrived in the chat view | `product_count`, `has_questions`, `latency_ms` |
| `yasan_search_link_click` | The visitor opened a link in a reply in the chat view | `link_url`, `position`, `surface` (`chat`) |

`surface` says where on the screen the product or row was, for example `primary` (main results), `recommended`, `category` or `chat`.

> **The old event has a new name**
>
> The `whisper_chatbot_product_recommendation_open` event is now `yasan_chatbot_product_click`, and `whisper_chatbot_product_recommendation_view` is now `yasan_chatbot_product_view`. If a report, audience or key event uses the old names, switch it to the new ones.

## Tips for Google Analytics

- Find the events in **Reports → Engagement → Events**. New events can take up to 48 hours to appear in reports; you can see them right away in **Realtime**.
- To count add-to-cart from the AI Sales Agent and AI Search as conversions, mark `yasan_chatbot_add_to_cart` and `yasan_search_add_to_cart` as **key events** in **Admin → Data display → Events**.
- To see parameters such as `position` or `surface` in reports, register them as custom dimensions in **Admin → Data display → Custom definitions**.

## Related articles

- [Statistics and Analytics](https://help.yasan.ai/en/analytics-and-statistics/)
- [Setting up cookie consent](https://help.yasan.ai/en/cookie-consent-setup/)
- [AI Sales Agent Overview](https://help.yasan.ai/en/ai-sales-agent-overview/)
- [Setting up AI Search](https://help.yasan.ai/en/setting-up-ai-search/)