Skip to content

Instantly share code, notes, and snippets.

@chavesm
Last active March 5, 2021 15:04
Show Gist options
  • Save chavesm/0876d95f38cf29b91f1562d0589e4c5f to your computer and use it in GitHub Desktop.
Save chavesm/0876d95f38cf29b91f1562d0589e4c5f to your computer and use it in GitHub Desktop.
Use the Crisp Chat JavaScript API to send an event to GA via MonsterInsights gtag version.
<script>
// Send an Crisp Chat event via gtag.
$crisp.push(["on", "chat:initiated", function() {
__gtagTracker('event', 'Test Event', {
'event_category' : 'test_event',
'event_action' : 'test_action',
'event_label' : 'This is a test event.'
});
}]);
</script>
<!-- Add to head section of page using proper enqueue
techniques or a plugin like Insert Headers and Footers. -->
@iamfilipp
Copy link

iamfilipp commented Mar 5, 2021

Hello Mark,

Thank for the reply, (Thomas on Ford New Motion)

I try your code but I cannot see any event from the following code.

<script> // Send an Crisp Chat event via gtag. $crisp.push(["on", "chat:initiated", function() { __gtagTracker('event', 'CrispInteractions', { 'event_category' : 'chatbox', 'event_action' : 'Chat Initiated', 'event_label' : 'Chat Initiated' }); }]); </script>

This is the help page from Crisp related to this issue. Could you please take a look?

https://help.crisp.chat/en/article/how-to-send-events-from-crisp-to-google-analytics-via-gtm-me6m5m/

Thanks in advance

Philip

@chavesm
Copy link
Author

chavesm commented Mar 5, 2021

Hi Philip,

We see the code installed on your site. But we don't know how to test it.

Can you give us the steps to start a chat?

Thanks!

Mark

@iamfilipp
Copy link

iamfilipp commented Mar 5, 2021 via email

@iamfilipp
Copy link

I have also add these events for better testing:

chat:opened

message:sent

message:received

@iamfilipp
Copy link

Update: It seems that events starting to appear on my analytics. Il let you know the next days how its going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment