Setting Up HubSpotUTK Cookie Tracking
How to set up Hubspot attribution to link contacts captured in Spara to hubspotutk cookie tracking data.
Prerequisites
Add the identify call
<script type="text/javascript" src="https://app.spara.co/embed-<app_id>.js"></script>
<script>
Spara = {
onUserMessageSent: function (text) {
// extract email from user message
function extractEmail(text) {
const match = text.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/);
return match ? match[0] : null;
}
const email = extractEmail(text);
if (window._hsq && email) {
window._hsq.push(["identify", { email }]);
window._hsq.push(["trackPageView"]);
}
},
}
</script>Single-page application (SPA) setup
Last updated