There were some steps missing in the Creating triggers part, apologies for that!
Once custom events open-or-close-whatsapp-chat
and click-start-chat-button
are created, you should add 2 Google Analytics tags and set the custom events as triggers for these tags:
Feel free to try it out and let me know if it worked 
I’d also like to note, that there is a simpler way to track clicks using the Google Analytics code.
To do this, please add this part of the code to your website <head>
:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ID');
</script>
In the code above, you need to replace G-ID with your actual website ID for Google
Analytics. This article will help you find your ID - Find your Google tag ID.
And then just add the rest of the script to the Custom JS field in your widget’s settings:
function sendAnalyticsEvent(config) {
if (typeof ga !== "undefined") {
ga('send', 'event', {
eventAction: config.action,
eventCategory: config.category,
eventLabel: config.label
});
}
if (typeof gtag !== "undefined") {
gtag('event', config.action, {
'event_category': config.category,
'event_label': config.label
});
}
}
document.addEventListener('click', function (event) {
const matchingItems = [
{
selector: '[class*="Bubble__BubbleComponent"]',
label: 'Open/Close Chat Widget'
},
{
selector: '[class*="ChatButton__DefaultButtonComponent-sc"]',
label: 'Click Start Chat Button'
},
];
matchingItems.forEach((item) => {
const match = event.target.closest(item.selector);
if (match) {
sendAnalyticsEvent({
action: 'click',
category: 'Elfsight Chat Widget',
label: item.label
});
}
});
});
Please let me know if it helps and if you have any other questions.