If Google Tag Manager is installed on your website, the Click to Chat plugin sends dataLayer Object.
We can use this dataLayer object and can create a custom event. ( in Google Analytics, Facebook Pixel, and many more places .. )
If you like to go in advance, we can use variables.
Step-1: Create a trigger
Triggers -> new
and at, ‘Trigger configuration’ –> at ‘others’ select – ‘Custom Event’
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/google-analytics.png)
Name the event ( here we added – Click to Chat )
and at trigger fires on select ‘some custom Events’.
select as ‘event’ – ‘contains’ – Click to Chat
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/Custom-Event-1.png)
Save the trigger.
Step-2: Tag
Create a tag and then assign it to Google Analytics 4.
at ‘Tags’ –> ‘New’
At ‘Tag configuration’, select where to send the event.
Here, we will use Google analytics 4 (GA4). So, let us select ‘Google Analytics – GA4 Event’
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/tag-type.png)
Configure the GA4 tag and name the event.
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/tag-configuration-1024x500.png)
and then, let us select when to trigger this. As we created a trigger, we will choose that.
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/choose-a-trigger-1024x132.png)
It looks like this.
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/click-to-chat-ga4-event-1024x524.png)
Save.
preview/submit and test it.
Now, When a user clicks on WhatsApp icon/Button, an event will be created at Google analytics.
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/event-count-by-event-name.png)
‘Click to Chat’ event.
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/click-to-chat-event.png)
Now, we know there is a click event.
Anyhow, google tag manager sends some values to the event, like the page_location, page_title, etc.
Now, we will check how to get the WhatsApp Number and attach it to the Event.
Click to Chat plugin sends some variables with the dataLayer.
Variable key: Variable Value
`event: 'Click to Chat',
type: 'chat',
number: id,
title: post_title,
url: url,
event_category: ga_category,
event_label: ga_label,
event_action: ga_action,`
The variable values are dynamic. we will use variable key to get the value at GTM and send it to Google Analytics.
Step-3: Variables
‘Variables’ at ‘User Defined Variables’ -> ‘New’
At ‘Variable Configuration’ select –> ‘Data Layer Variable’.
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/variable.png)
(Click to Chat sends multiple variables, here we will add a number, type variable)
Number: we will get the WhatsApp number.
Type: chat/group/share.
and at ‘Data Layer Variable Name’ add the Variable Key – ‘number’.
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/number-1024x459.png)
Save it.
and we will add ‘type’ variable. (repeat the steps)
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/type-1024x492.png)
Save it.
Let us attach this variable to the event tag.
Go the tag where it is created earlier. At the Event, Parameters we will add the variables.
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/GA4-event.gif)
Save it.
Preview/Submit and Test.
When the user clicks on the WhatsApp icon/button, an event will be sent to Google Analytics.
![](https://cdn.holithemes.com/plugins/click-to-chat/wp-content/uploads/2021/06/event-count-by-event-name-1.png)
Here, we can notice the variables added to google analytics – WhatsApp Number, Chat/Group/Share
if we navigate to the Number we can check the number.