If Google Tag Manager is installed on our website, the Click to Chat plugin automatically pushes a dataLayer object when the WhatsApp button is clicked.
We can use this dataLayer
to create a custom event for platforms like Google Analytics, Facebook Pixel, and more. For advanced tracking, we can also use variables to capture additional event details like the WhatsApp number or event type.
Step-1: Create a Trigger in GTM
- In GTM, go to Triggers → New
- Under Trigger Configuration, choose Custom Event (under “Other”)

- Set the Custom Event Name to Click to Chat
- Under “This trigger fires on,” select Some Custom Events
- Define the condition:
Event
→ contains
→ Click to Chat
- Save the trigger
Step 2: Create a Tag for Google Analytics 4
- Navigate to Tags → New
- Under Tag Configuration, select Google Analytics: GA4 Event
- Under Event Name, enter a name like click_to_chat
- In the Triggering section, select the custom trigger created in Step 1
- It looks like this.
- Save the tag
✅ Now, when users click the WhatsApp button, this event will be recorded in Google Analytics as click_to_chat.
- ‘Click to Chat’ event.
- We already know that a click event is triggered.
- Google Tag Manager automatically sends some values with the event, such as
page_location
,page_title
, and others.
- Now, we will see how to capture the WhatsApp number and attach it to the event.
- The Click to Chat plugin pushes certain variables to the
dataLayer
, including the WhatsApp number.
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: Create Data Layer Variables
- Go to Variables → User-Defined Variables → New
- Select Variable Configuration → Data Layer Variable
Click to Chat sends multiple variables to the dataLayer
.
Here, we will add two variables:
number
: WhatsApp numbertype
: chat / group / share
- In Data Layer Variable Name, enter the key we want to extract (e.g., number)
- Save the variable
Repeat these steps to create variables for other values like:
type
(chat/group/share)
event_category
event_label
, etc.
Step 4: Add Variables to the Event Tag
Let us attach this variable to the event tag.
- Scroll to Event Parameters and add the variables:
- Name:
whatsapp_number
→ Value:{{WhatsApp Number}}
- Name:
Chat/Group/Share
→ Value:{{Type}}
- Name:
- Save the tag
- Preview/Submit and Test.
- When the user clicks on the WhatsApp icon/button, an event will be sent to Google Analytics.
Conclusion
With this setup, we can accurately track WhatsApp button clicks using Google Tag Manager and send detailed event data—such as the WhatsApp number and interaction type—to platforms like Google Analytics 4. This allows us to gain deeper insights into user behavior and optimize our engagement strategies accordingly.