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.

Integration


Steps

  1. 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.

  2. Add a line of code for each conversion – see SDK reference below

Basic example

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>

Consent management


Native integrations