This document is a work in progress. If you feel there is information missing please email [email protected]
Refer to Event/property names reference – Datahappy for reserved event/property names.
Add the datahappy pixel high up in the <head>
section of each page on your website
The SDK loads asynchronously so won’t slow down page load times.
Add a line of code for each conversion – see SDK reference below
Let’s imagine you have a lead form on your website, built with Tally.
Here’s how you would detect a form submission, track the lead event with datahappy and then redirect to a thank you page on success.
<script>
window.addEventListener('message', function(e) {
if (e?.data && e.data.includes('Tally.FormSubmitted')) {
// prepare form data entered by the lead
const userTraits = e.data.reduce((obj, item) => {
obj[item.id] = item.value
return obj
}, {})
// track lead event
datahappy.trackLeadCreation({
userTraits,
eventProperties: {
value: 10,
currency: "GBP"
}
}).then(() => window.location.href = "/thank-you")
}
})
</script>