Zendesk is messing with my analytics

Recently one of the sites I work on decided they wanted to switch over to Zendesk. It’s a great tool for chat and support. The UX person said they were just going to put the GA ID into the field provided in the back end and Bob’s your father’s brother. What could be wrong, in his words - “It’s a global leading software, I’m sure their tracking would be better than what we could do”.

Firstly, never assume that software that doesn’t specialise in data knows how to collect data. Also, a global companies blanket solution to tracking may not fit your needs.

That said, Zendesk tracking is …technically speaking…wack. The main integration manages to hijack your GA object and send events via your custom task. What does that mean? If you are using Google Tag Manager, it will send the event with all the custom dimensions and metrics you had set with your previous hit. So you could end up with things like this:

Screen Shot 2021-01-20 at 10.05.57 am.png

This means that if you wanted to send all your events to a different property, you can’t. Just try putting a different property ID into their config and you will see that it sends it to which ever property last sent a hit, not the one specified.

That’s not the worst bit, though. It just sends soooooooo many events and the same events multiple times.

This means your unique events are vastly different from your total events and very hard to use the total events.

image (1).png

And this:

user-explorer.PNG

Just by opening the chat, it sends 3 events:

  • Chat Opened

  • Chat Shown

  • Web Widget Opened

What’s more, it sends them as interactive events. So we don’t have the choice if it affects our bounce rate.

So, that’s what’s wrong, but how can we fix it.

Take back control of the events

The first step is to turn off the default integration. You can then use a custom HTML tag in Tag Manager to track the events via the dataLayer, using this code.

<script type="text/javascript">
  zE('webWidget:on', 'userEvent', function(event) {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      "event": 'custom.zendesk.widget'
      "eventCategory": event.category,
      "eventAction": event.action,
      "eventLabel": event.properties
    });
  });
</script>

You will need to set up the corresponding variables, triggers and tags to send to Google Analytics.

This will then allow you to add whatever custom dimensions and metrics you would like.

You may still find that it is sending the same event multiple times. Who knows why it does this but I think I have a solution.

Check if it fired before

There is the option to fire once per page, or even once per session in Google Tag Manager. Though this doesn’t help with single-page apps, where you want the event to fire more than once but not three times in a second period. So, as a bit of a hack, let’s check if it has fired in the last second.

<script type="text/javascript">
  zE('webWidget:on', 'userEvent', function(event) {
    window.dataLayer = window.dataLayer || [];
    hasFired = false;
    for(var i=0; i< window.dataLayer.length; i++){
      if(window.dataLayer[i].event == 'custom.zendesk.widget' & 
window.dataLayer[i].eventCategory ==  event.category & 
window.dataLayer[i].eventAction == event.action & 
Math.floor(Date.now() / 1000)-window.dataLayer[i].timestamp<1){
        hasFired = true;
        break;
      }
    }
    if(!hasFired){
    window.dataLayer.push({
      "event": 'custom.zendesk.widget'
      "eventCategory": event.category,
      "eventAction": event.action,
      "eventLabel": event.properties,
      "timestamp": Math.floor(Date.now() / 1000)
    });
    }
  });
</script>

This should help fix some of Zendesk tracking problems. Maybe they will fix theirs one day but in the meantime, it keeps us analysts employed!

Thanks, to Kristi Barrow of Kritikality, a Digital Data and Marketing Technology Consultancy for helping me confirm similar problems she has seen with her clients.

Previous
Previous

Success will be measured by...

Next
Next

Should I be A/B Testing?