{"id":5481,"date":"2023-01-09T12:11:24","date_gmt":"2023-01-09T09:11:24","guid":{"rendered":"https:\/\/trackingchef.com\/?p=5481"},"modified":"2023-02-22T17:51:01","modified_gmt":"2023-02-22T14:51:01","slug":"integrating-the-zendesk-widget-with-ga4","status":"publish","type":"post","link":"https:\/\/trackingchef.com\/google-analytics\/integrating-the-zendesk-widget-with-ga4\/","title":{"rendered":"Integrating the Zendesk Widget with GA4"},"content":{"rendered":"\n

If you’re already using Zendesk to power chat on your site, you probably already have it integrated into your Google Analytics account to report on events. Just like other popular tools, Zendesk hasn’t yet released a native GA4 integration for their product.<\/p>\n\n\n\n

In this guide, I’ll walk through two methods of integrating the Classic Zendesk Web Widget with GA4. The new Zendesk Web Widget has a different API with fewer integration options<\/a>, so I’ve detailed these separately at the bottom of the post.<\/p>\n\n\n\n

\n

Important note:<\/strong> In both scenarios you will also need to create a matching Custom Dimension in Google Analytics to be able to report on the specific actions taken in Zendesk<\/p>\n<\/blockquote>\n\n\n\n

Google Tag Manager (recommended)<\/h2>\n\n\n\n

Adding the GA4 event using GTM (Google Tag Manager) is simple.<\/p>\n\n\n\n

Step 1: Add Custom HTML Listener Tag<\/h3>\n\n\n\n

In your GTM containers, create a new Custom HTML tag and name it “Zendesk Listener”.<\/p>\n\n\n\n

Paste in the tag the following snippet:<\/p>\n\n\n\n

<script>\n  if (window.zE) {\n    zE('webWidget:on', 'userEvent', function(event) {\n        dataLayer.push({\n          'event':'zendesk_event',\n          'zendesk_action': event.action\n        });\n    });\n}\n<\/script><\/code><\/pre>\n\n\n\n

Add a trigger to fire the tag on all pages and save the tag.<\/p>\n\n\n

\n
\"image-1593026\"
Custom HTML tag with Zendesk event listener<\/figcaption><\/figure><\/div>\n\n\n

Step 2: Create a new variable to capture the events<\/h3>\n\n\n\n

Create a new variable of the type Data Layer Variable named zendesk_action<\/em>.<\/p>\n\n\n

\n
\"image-8853877\"<\/figure><\/div>\n\n\n

Step 3: Create a new trigger<\/h3>\n\n\n\n

Create a new trigger of the type Custom Event. The event’s name should be set to zendesk_event<\/em>.<\/p>\n\n\n

\n
\"image-6807136\"<\/figure><\/div>\n\n\n

Step 4: Add a GA4 event tag<\/h3>\n\n\n\n

Next, create a new GA4 Event tag and associate it with the relevant GA4 Configuration Tag.<\/p>\n\n\n\n

Set the Event Name to {{Event}}<\/em>.<\/p>\n\n\n

\n
\"image-5716629\"<\/figure><\/div>\n\n\n

Add a new event parameter called zendesk_action<\/em>. Pair the parameter with the variable created as its value.<\/p>\n\n\n\n

You can of course alter the zendesk_action<\/em> to use any parameter name of your choice.<\/p>\n\n\n

\n
\"image-7276005\"<\/figure><\/div>\n\n\n

Finally, add the trigger you created to the event tag and you’re all set.<\/p>\n\n\n

\n
\"image-4395507\"
The full GA4 Event for Zendesk<\/figcaption><\/figure><\/div>\n\n\n

Manual integration<\/h2>\n\n\n\n

If you’re not using GTM on your site, you can simply add this snippet to track any Zendesk event on your site.<\/p>\n\n\n\n

This script checks for the presence of the zE method, indicating that the Zendesk widget is active, in conjunction with the GTAG snippet present. Only if both exist, it will trigger the relevant events to GA4.<\/p>\n\n\n\n

if (window.zE && window.gtag) {\n    zE('webWidget:on', 'userEvent', function(event) {\n        gtag('event', 'zendesk_event',{\n            'zendesk_action': event.action\n        });\n    });\n}<\/code><\/pre>\n\n\n\n

Be sure to create a Custom Dimension in Google Analytics so that the zendesk_action<\/em> will be available in reports.<\/p>\n\n\n\n

You can of course alter the zendesk_action<\/em> to use any parameter name of your choice.<\/p>\n\n\n\n

Tracking the new Zendesk Web Widget<\/h2>\n\n\n\n

As mentioned above, the new Web Widget comes with fewer events, so tracking is significantly different for it.<\/p>\n\n\n\n

The two key events that can be tracked are the opening and closing of the chat widget.<\/p>\n\n\n\n

Google Tag Manager set up<\/h3>\n\n\n\n

Similar to the setup of the legacy web widget, you will need to create a Custom HTML tag.<\/p>\n\n\n\n

Widget open<\/strong><\/p>\n\n\n\n

if (window.zE) {\n    zE('messenger:on', 'open', function() {\n        dataLayer.push({\n            'event': 'zendesk_open',\n        });\n    });\n}<\/code><\/pre>\n\n\n\n

Widget close<\/strong><\/p>\n\n\n\n

if (window.zE) {\n    zE('messenger:on', 'close', function() {\n        dataLayer.push({\n            'event': 'zendesk_close',\n        });\n    });\n}<\/code><\/pre>\n\n\n\n

The rest of the setup is similar, with the GA4 Event tag using only the event’s name and a trigger with the Zendesk events.<\/p>\n\n\n

\n
\"image-2045869\"<\/figure><\/div>\n\n\n

Manual set up<\/h3>\n\n\n\n

Similarly, the setup for the manual tags will use the two events.<\/p>\n\n\n\n

Widget open<\/strong><\/p>\n\n\n\n

if (window.zE && window.gtag) {\n    zE('messenger:on', 'open', function() {\n        gtag('event', 'zendesk_open');\n    });\n}<\/code><\/pre>\n\n\n\n

Widget close<\/strong><\/p>\n\n\n\n

if (window.zE && window.gtag) {\n    zE('messenger:on', 'close', function() {\n        gtag('event', 'zendesk_close');\n    });\n}<\/code><\/pre>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

If you’re already using Zendesk to power chat on your site, you probably already have it integrated into your Google Analytics account to report on events. Just like other popular tools, Zendesk hasn’t yet released a native GA4 integration for their product. In this guide, I’ll walk through two methods of integrating the Classic Zendesk […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,39],"tags":[],"_links":{"self":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/5481"}],"collection":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/comments?post=5481"}],"version-history":[{"count":6,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/5481\/revisions"}],"predecessor-version":[{"id":5542,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/5481\/revisions\/5542"}],"wp:attachment":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/media?parent=5481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/categories?post=5481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/tags?post=5481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}