en рус

Javascript Events

Now 3 events are generated:

  • tocha:open-chat-window when the user opens the chat window< /li>
  • tocha:first-message-send when the user writes the first message in a chat
  • tocha:message-send when a user writes a message in a chat

If you monitor the conversion of your site, events can be used to track goals in Yandex.Metrica or Google Analytics.

JavaScript events

Yandex. Metrics:

document.addEventListener('tocha:loaded', () => { let te = document.getElementsByTagName('telegram-web-chat')[0]; te.addEventListener('tocha:first-message-send', (e) => { ym(1234567,'reachGoal','first-message-send'); }); te.addEventListener( 'tocha:message-send', (e) => { ym(1234567,'reachGoal','message-send'); }); te.addEventListener('tocha:open-c hat-window', (e) => { ym(1234567,'reachGoal','open-chat'); });});

More about setting goals in Yandex.Metrica< /p>