Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ryanpraski/7606e20b7c05079fa4f67be1478b8789 to your computer and use it in GitHub Desktop.
Save ryanpraski/7606e20b7c05079fa4f67be1478b8789 to your computer and use it in GitHub Desktop.
drift google tag manager gtm dataLayer event listeners for chat widget including playbook interactions and meeting bookings
<script>
window.drift.on('ready',function(api){
window.drift.on('message:sent',function(event){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'message sent',
'eventLabel': 'drift>message sent conversation id: ' + event.conversationId
});
}
})
window.drift.on('startConversation',function(event){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'start conversation',
'eventLabel': 'drift>start conversation id: ' + event.conversationId
});
}
})
window.drift.on('emailCapture',function(event){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'email capture',
'eventLabel': 'drift>email capture'
});
}
})
window.drift.on('welcomeMessage:open',function(e){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'welcome message open',
'eventLabel': 'drift>welcome message open'
});
}
})
window.drift.on('welcomeMessage:close',function(e){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'welcome message closed',
'eventLabel': 'drift>welcome message closed'
});
}
})
window.drift.on('sidebarOpen',function(e){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'sidebar open',
'eventLabel': 'drift>sidebar open'
});
}
})
window.drift.on('sidebarClose',function(e){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'sidebar close',
'eventLabel': 'drift>sidebar close'
});
}
})
window.drift.on('campaign:open',function(event){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'campaign open',
'eventLabel': 'drift>campaign open id: ' + event.campaignId
});
}
})
window.drift.on('campaign:dismiss',function(event){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'campaign dismiss',
'eventLabel': 'drift>campaign dismiss id: ' + event.campaignId
});
}
})
window.drift.on('campaign:click',function(event){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'campaign click',
'eventLabel': 'drift>campaign click id: ' + event.campaignId
});
}
})
window.drift.on('campaign:submit',function(event){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'campaign submit',
'eventLabel': 'drift>campaign submit id: ' + event.campaignId
});
}
})
window.drift.on('scheduling:meetingBooked',function(event){
{
dataLayer.push({
'event': 'driftInteraction',
'eventCategory': 'drift',
'eventAction': 'meeting booked',
'eventLabel': 'drift>meeting booked'
});
}
})
})
</script>
@ryanpraski
Copy link
Author

This is implemented on www.ryanpraski.com

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