Adding Action Conversion Pixels To HubSpot Forms

You can set goals to be triggered when the visitor reaches a URL (as a destination goal) or by action conversion. This post is for HubSpot users who need to track goals that can’t be defined according to URL.

1. Go to the “Add Goal/Event” and choose Goal Type: Action conversion

 

2. After clicking the ‘Save’ button, the pixel will be generated:

pixel3.  Copy the pixel img src value.

4. Search for the HubSpot form:

4. When using the Form’s embedded code, add this piece of code after the formID line:

onFormSubmit: function($form) {      
    var trd_pixel = document.createElement(“img”);
    trd_pixel.setAttribute(‘src’, ‘https://prod.trendemon.com/apis/loadflame/pixel?user_id=1234&conv_id=1234‘);   
}

Notice, the  ‘user_id=___&conv_id=___’ should be the same as in the pixel.

For example, here is how the embedded code should look like:

<!–[if lte IE 8]>
<script charset=”utf-8″ type=”text/javascript” src=”//js.hsforms.net/forms/v2-legacy.js”></script>
<![endif]–>
<script charset=”utf-8″ type=”text/javascript” src=”//js.hsforms.net/forms/v2.js”></script>
<script>
   hbspt.forms.create({
       portalId: “4644841”,
       formId: “d77cc949-4163-4e5f-83e3-7c0a8bed21df”,
 onFormSubmit: function($form) {       
           var trd_pixel = document.createElement(“img”);
           trd_pixel.setAttribute(‘src’, ‘https://prod.trendemon.com/apis/loadflame/pixel?user_id=1234&conv_id=1234′); 
        }
    });
</script>