When a user clicks on the WhatsApp icon or button, an event is triggered in Google Analytics. This event is set up to capture specific details without requiring the installation of Google Analytics itself, as it integrates seamlessly with an existing setup.
For users with Google Analytics , custom event parameters can be utilized. The previously used parameters such as Category, Label, and Action are no longer necessary.
Event Configuration:
- Event Name:
click_to_chat
This name is used to identify the “Click to Chat” event in Google Analytics reports.
Event Parameters:
- Number: This parameter captures a unique identifier related to the chat session or counts the number of times the chat button has been clicked.
- Title: This represents the title of the page where the event occurred, helping to identify the specific page the user was on.
- URL: This captures the full URL of the page where the event took place, allowing for precise tracking of where the interaction happened.
Advanced Configuration:
To enhance tracking, additional information from URL parameters or cookies can be included in the event. For instance:
- URL Parameters: To capture details like campaign parameters, you can extract values directly from the URL using square brackets around the parameter name (e.g.,
[gclid]
,[utm_source]
). - Cookies: Values from cookies can also be retrieved using double square brackets around the cookie name (e.g.,
[[_ga]]
).
Example Setup:
htmlCopy code<script>
gtag('event', 'click_to_chat', {
'event_category': 'engagement',
'event_label': '{title}',
'value': '{number}',
'page_url': '{url}',
'gclid': '[gclid]',
'_ga': '[[_ga]]'
});
</script>
In this example:
{title}
is replaced by the page title.{url}
is the current page URL.{number}
is your unique chat identifier.[gclid]
extracts the value from the URL.[[_ga]]
fetches the Google Analytics cookie value.
By implementing this setup, all relevant data related to the “Click to Chat” event will be captured, providing valuable insights into user interactions.