Send Data to Google Analytics

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!

One Click Integration

An alternative to using the Javascript SDK is our one-click app that integrates your Drift with Google Analytics. Check it out here!

Sending Events to Google Analytics

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.

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.

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>

Goal set up for Drift events

If you'd like to connect Drift events to goals such as conversions, you can read our tutorial here.

Send Data to Google Analytics