If you are using Drift as your chatbot you want to ensure that all email addresses collected through the Drift chatbot are captured by RollWorks and optionally marked this event as a Conversion Audience.
Share this article with your Website Developer to configure your Pixel so that RollWorks can track email addresses submitted via Drift, and other Drift conversation events.
Good to know before you start
- Drift chat boxes and forms can be delivered in an iframe.
- Drift has a javascript API that allows the Pixel to listen to events that are dispatched from Drift. This API is accessible on all pages running a Drift chatbot.
- See Drift Events to get a full list of all supported events.
Track email addresses submitted via the Drift Chatbox
To track emails submitted via Drift by your visitors, and assuming the form is integrated using an iframe you can use the script below to pass the email address to RollWorks.
Developer Notes
- Our emailc endpoint should be called when Drift’s emailCapture event, which provides the email value.
- You must substitute the advertisable_EID/PIXEL_EID highlighted below.
- Click here for more information about capturing email addresses submitted by visitors via Drift.
<script type="text/javascript">
if (window.drift) {
window.drift.on("emailCapture", function(e) {
if (e && e.data && e.data.email) {
var email = e.data.email;
var img = document.createElement('img');
img.src = '//d.adroll.com/lc/ADVERTISABLE_EID/PIXEL_EID?' +
'adroll_external_data=ipixel%3D1%26adroll_email%3D' +
encodeURIComponent(email);
}
});
}
</script>
Track email addresses submitted via the Drift Chatbox as Conversions
We recommend flagging all email submissions on your website as Conversion Audiences in RollWorks. You can track email submissions from Drift and flag them as conversions using the snippet below.
<script type="text/javascript">
if (window.drift) {
window.drift.on("emailCapture", function(e) {
if (e && e.data && e.data.email) {
var email = e.data.email;
var img = document.createElement('img');
img.src = '//d.adroll.com/emailc/ADVERTISABLE_EID/PIXEL_EID?' +
'adroll_external_data=ipixel%3D1%26adroll_email%3D' +
encodeURIComponent(email);
}
try {
__adroll.record_user({"adroll_segments": "SEGMENT_ID"});
} catch (err) {}
});
}
</script>
Track other Drift conversation events
To track other Conversation Events from Drift, and assuming the form is integrated using an iframe you can use the script below to pass the event to RollWorks.
Developer Notes
- Use the startConversation Drift event to track conversation events.
- You must substitute the SEGMENT_ID highlighted below.
<script type="text/javascript">
if (window.drift) {
window.drift.on('ready', function(api, payload) {
window.drift.on('startConversation', function(data) {
try {
__adroll.record_user({"adroll_segments": "SEGMENT_ID"});
} catch (err) {}
});
});
}
</script>
Troubleshooting Drift event availability
If the Drift chatbot doesn’t load immediately on page load, which can cause the window to.drift variable to not load immediately, we suggest using the snippet below.
Developer Notes
- This snippet will timeout and wait for window.drift variable until it’s available
- You must substitute the advertisable_EID/PIXEL_EID highlighted below.
- You must substitute the SEGMENT_ID highlighted below.
<script type="text/javascript">
function checkDriftChat() {
if (window.drift) {
console.log('RollWorks ' + window.drift.on);
window.drift.on("emailCapture", function(e) {
if (e && e.data && e.data.email) {
var email = e.data.email;
var img = document.createElement('img');
img.src = '//d.adroll.com/emailc/ADVERTISABLE_EID/PIXEL_EID?' +
'adroll_external_data=ipixel%3D1%26adroll_email%3D' +
encodeURIComponent(email);
}
try {
__adroll.record_user({"adroll_segments": "SEGMENT_ID"});
} catch (err) {}
})
}
else {
setTimeout(function() {
checkDriftChat();
}, 200);
}
};
checkDriftChat();
</script>