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".Ā