In Sri Lanka, WhatsApp is how customers ask questions, request quotes and book appointments. If your website has a WhatsApp button but you don't track it, you're blind to most of your enquiries, and your SEO reports will undervalue organic search.
Here's how to track WhatsApp clicks in Google Analytics 4.
What we're tracking
A click on any link that opens WhatsApp. These usually look like:
https://wa.me/94771234567https://api.whatsapp.com/send?phone=94771234567whatsapp://send?phone=...
We can't see whether the visitor actually sent the message, but the click is a strong intent signal.
Option 1: Google Tag Manager (recommended)
1. Install Tag Manager
If you haven't already, create a GTM container and add its code to your site. Add your GA4 configuration tag (the Google tag) with your Measurement ID.
2. Enable click variables
In Variables, Configure, enable Click URL and Click Text.
3. Create a trigger
- Trigger type: Click - Just Links
- Fire on: Some Link Clicks
- Condition: Click URL matches RegEx
wa\.me|api\.whatsapp\.com|whatsapp://
4. Create a GA4 event tag
- Tag type: Google Analytics: GA4 Event
- Event name:
whatsapp_click - Event parameters (optional):
link_url= {{Click URL}},link_text= {{Click Text}},page_location= {{Page URL}} - Trigger: the WhatsApp trigger above
5. Test
Use GTM's Preview mode, click your WhatsApp button and confirm the tag fires. Then check Realtime or DebugView in GA4.
6. Publish and mark as a key event
Publish the container. After the event appears in GA4 (it can take up to 24 hours), go to Admin, Events and mark whatsapp_click as a key event.
Option 2: Directly in your site code
If you're not using Tag Manager and your site already loads gtag.js, add a small script:
<script>
document.addEventListener('click', function (e) {
var a = e.target.closest('a[href*="wa.me"], a[href*="api.whatsapp.com"]');
if (a && window.gtag) {
gtag('event', 'whatsapp_click', { link_url: a.href });
}
});
</script>
Then mark the event as a key event in GA4, as above.
Track phone calls the same way
Create another trigger where Click URL starts with tel: and an event named phone_click. On mobile, many visitors tap your number instead of filling a form.
Make WhatsApp enquiries more useful
- Pre-fill the message:
https://wa.me/94771234567?text=Hi%2C%20I%20found%20you%20on%20Googlehelps you know the enquiry came from your website. - Use different pre-filled messages for different pages or services, so you know what each customer asked about.
- Count real enquiries each month and compare with clicks.
Reading the results
In GA4, go to Reports, Acquisition, Traffic acquisition and add the key event column for whatsapp_click. Now you can see how many WhatsApp enquiries come from organic search, Facebook, Google Ads and so on.
Need it done for you?
We set up WhatsApp, phone, form and purchase tracking as part of our Google Analytics setup service. See also the full GA4 setup guide.