Widget events (to send to things like 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!

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:

// Register an event handler for `startConversation` events
window.drift.on("startConversation", function() {
  console.log("started a new chat!");
  // send the event to Google Analytics
  window.ga("send", "event", "Drift", "startConversation");
});

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.


Was this article helpful?

Can’t find what you’re looking for?

Talk To Us