Send Data to Google Analytics

Updated 14 days ago ​by Matt Bilotti

If you're trying to send Drift events from the JavaScript SDK to Google Analytics, or any other system, to measure when conversations are started, you're in luck!

Each time a conversation is started, the Drift widget fires off a startConversation event.  The JavaScript SDK's on method lets you subscribe to those events and provide a function that is called whenever the event occurs.

Sending "Start Conversation" Events to Google Analytics 

In this example, we subscribe to startConversation events with a function that tracks them in Google Analytics:

<script>
window.drift.on('startConversation', function() {ga('send', 'event', 'Drift Widget', 'Chat Started'); });
window.drift.on("emailCapture", function(data) {ga('send', 'event', 'Drift Widget', 'Email Captured'); });
window.drift.on("scheduling:meetingBooked", function(data) {ga('send', 'event', 'Drift Widget', 'Meeting Booked'); });
</script>

Here's an article that explains how to send  events to Google Analytics in case you need it. 

If you're already integrated with analytics.js (also can be used if you're a Segment Integration user), just listen for startConversation, pass that along to wherever you want, and you'll be all set.

How to Track Drift Events in GA using Google Tag Manager

If the script is implemented through Google Tag Manager and you are having issues, you might need to specify the tracker. 

This can be done by adding the following code snippet as a new Tag with the Trigger being "Pageview" 

<script>
    window.drift.on('startConversation', function() {
    ga('send', 'event', 'Drift Widget', 'Chat Started');
    console.log('Chat Started'); /* Can be commented out */
    });
  window.drift.on("emailCapture", function(data) {
    ga('send', 'event', 'Drift Widget', 'Email Captured');
    console.log('Email Captured'); /* Can be commented out */
    });
  window.drift.on("scheduling:meetingBooked", function(data) {
    ga('send', 'event', 'Drift Widget', 'Meeting Booked');
    console.log('Meeting Booked'); /* Can be commented out */
    });
</script>
Here is the complete list of events we track.

Was this article helpful?

Can’t find what you’re looking for?

Talk To Us