Legacy: Prevent Marketo forms field from being hidden if Clearbit JS doesn't load (No Reveal)

🔍 Please note: This article is for customers on Standard Bundle, Reveal, or Clearbit Platform plans.

Problem: 

Some Ad or Script Blockers can prevent the many scripts including the Clearbit Tag from loading on your site. This can cause issues where users can submit a form without all of the required fields or can even prevent a site visitor from submitting it altogether. 

 

Solution: 

One solution we can recommend here is to change the default visibility of your Marketo form fields to Visible, instead of Hidden and only set those fields to 'hidden' if we get confirmation that the Clearbit Tag has loaded. Here are the following steps to achieve this: 

 

(1) Add a default value of false to the Clearbit Form Status field in Marketo.

(2) Update each field's visibility rules to first check for the Clearbit Form Status field to be true, rather than 'empty'.

(3) Since we are not using Clearbit Reveal in this case, we would need to add the following snippet in Google Tag Manager, to the same Tag that loads the Clearbit Form Script.

script.onload = function () {
dataLayer.push({
event: "Clearbit Form JS loaded"
}); };

Copy the above JS snippet and add it above the line that reads

script.onerror = function (e) {

(4) Create a custom trigger with the same name as the event we are creating in the snippet above. In this case, the Event Name we are using is "Clearbit Form JS loaded" (case sensitive)

(5) Finally, create a custom HTML tag that fires when Clearbit loads, checks that a Marketo form exists, and updates the Clearbit Form Status field's value to true. 

<script>
  if (MktoForms2) {
    MktoForms2.whenReady(function(form) {
      form.setValues({
        clearbitFormStatus: "true"
      })
    })
  }
</script>

User the trigger that we created in step (4) "Clearbit Form JS loaded".