Uploaded image for project: 'Planet4'
  1. Planet4
  2. PLANET-6146

Add Hubspot event callback script to track form signups

    XporterXMLWordPrintable

    Details

    • Type: Task
    • Status: CLOSED
    • Priority: Should have
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.58.2
    • Labels:
      None
    • Story Points:
      3
    • Sprint:
      Sprint #162, Sprint #163
    • Section:
      Analytics, Integrations
    • P4 site:
      All sites
    • Track:
      Development
    • Epic Link:
    • P4 Test Environment:
      jupiter
    • Repositories:
      planet4-master-theme

      Description

      Context

      We need to find a solution for tracking Hubspot forms in Planet 4 pages that aligns with the current tracking setup we use for the Engaging Networks Form Block. 

      Task

      As we are doing for Hubspot Landing Pages, we can implement an event listener (provided by Hubspot documentation) on Planet 4 pages that will capture any signups happening on HS Forms. 

      The script should capture the event and fire a dataLayer event once the signup is successful. We can use the dataLayer standards events such as formSubmission to facilitate the Google Analytics events set up in Google Tag Manager.

       

      Script

      <!-- Hubspot Form Event Listener: Form Submission -->
      <script type="text/javascript">
      window.addEventListener("message", function(event) {
      if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') {
      window.dataLayer.push({
      'event': 'formSubmission',
      'hs-form-guid': event.data.id
      });
      }
      });
      </script>
      <!-- END Hubspot Form Event Listener: Form Submission -->
       

      Test

      **We must test if the script is firing the correct dataLayer event once the signup is completed. Important to test if the event is captured in Google Tag Manager in the following page and different use cases:

      1. Form with inline thank you message
      2. Form with redirect to a Hubspot page
      3. Form with redirect to a Planet 4 page
      4. Form set as RAW HTML 

      Notes

      So far, the method of using the callback script to track form submissions is not working with Hubspot pop-up forms.

      Comment on this forum: "Pop-up forms don't currently trigger global form events".

       

       

        Gliffy Diagrams

          Attachments

            Activity

              People

              Assignee:
              mleray Maud Leray
              Reporter:
              jmarubay Julia Marubayashi
              Tester:
              Julia Marubayashi
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: