Tracking Hubspot Forms

Description

Hubspot forms are special forms that can be tracked in Convert by adding some JavaScript code to the app interface with which you can track them.

 

Configuration

  1.  Create a Custom Js Goal.

    First, create a goal using the Javascript Triggered Goal template:



    Reopen it and copy the goal id.

  2. Then add the following code to the following the Project > Configuration > Global Javascript Section. First, replace the URL in the code (https://www.convert.com/pricing/) with the URL of where the form you want to track exists. Then Replace the 12345678 with the goal id for your new goal.
    if (location.href.startsWith('https://www.convert.com/pricing/')) {
     window.addEventListener("message", function(event) { 
    if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') { window.dataLayer.push({
    window._conv_q = window._conv_q || []; _conv_q.push(["triggerConversion","12345678"]);
    }
    });
    }

    Please test your goal while being bucketed on a test. Verify that is tracking correctly.

Tracking Multiple Hubspot Forms on the Site.

  1. Create a Javascript Triggered goal for each form you want to track. Write their goal id down. 
  2. Add the code shown in the step before repeatedly for each goal you want to track, and change the corresponding URL where each of the forms is located. 
  3. Test your goals. 
Need assistance? Start a conversation with our Support Team.
CONVERT MORE

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

START 15-DAY FREE TRIAL
✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features

Comments