Dev Request: Dev Request - Hubspot Forms API Submission

Status: Complete
Last updated: November 08, 2022 3:47 PM MST
Originally delivered at: October 28, 2021 6:00 PM MDT

Instructions

Intro

When the Google Tag Manager library loads it declares a global JS object, dataLayer. It overloads the array prototype .push method so that it can grab on to objects/"events" pushed to that array.

Notes/Questions

  • What values are possible there for customer.status?
  • Populate customer.hubspot_canonical_vid, customer.auth0_id, customer.chargebee_id, customer.status if available. If not available, keep the key and use value javascript undefined.

Other Notes

data.context.hutk is the hubspot user token if available, if not set to JS undefined

data.form_data.fields is an object of key-value pairs for each form field and its value

Data Layer Event: hubspot_forms_api_submit

Triggering Conditions

Event to Log

<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    'event': 'hubspot_forms_api_submit',
    'data': {
      "context": {
        "ID--_____hubspot_forms_api_submit_____context--hutk_____uiName--hutk": "INSERT HUBSPOT USER TOKEN"
      },
      "ID--_____hubspot_forms_api_submit_____form_id_____uiName--form_id": "INSERT HUBSPOT FORM ID",
      "customer": {
        "ID--_____hubspot_forms_api_submit_____customer--status_____uiName--status": "Chargebee Cx status (e.g. in_trial) or JS undefined",
        "ID--_____hubspot_forms_api_submit_____customer--auth0_id_____uiName--auth0_id": "ID or JS undefined",
        "ID--_____hubspot_forms_api_submit_____customer--chargebee_id_____uiName--chargebee_id": "ID or JS undefined",
        "ID--_____hubspot_forms_api_submit_____customer--hubspot_canonical_vid_____uiName--hubspot_canonical_vid": "ID or JS undefined"
      },
      "form_data": {
        "fields": {
          "ID--_____hubspot_forms_api_submit_____form_data--fields--key_____uiName--key": "value",
          "ID--_____hubspot_forms_api_submit_____form_data--fields--key2_____uiName--key2": "value2"
        }
      }
    }
  });
</script>