‹ Back to Knowledge Base home

Woah there, partner! This is an advanced topic that involves custom script. Troubleshooting custom script is outside of Pardot Support’s scope, so proceed with caution.

Occasionally you may want to make the redirect location of a Pardot form dynamic. To do this, you can pass the URL into the form via a hidden field and then call that URL with JavaScript in the form’s Thank You Content.

Instructions

  1. Create a custom field to store your redirect URL and set type to Hidden. Make sure this field is NOT set to record and display multiple responses, as this will cause an error in the redirect. Note the field’s ID.
  2. Edit your form. On Step 2, add your hidden field. Go to the Advanced section and mark Always display even if previously completed. Save the field.
  3. While editing your form on Step 4 add the following JavaScript to your form’s Thank You Code. You will need to update the two places where you see field_id towards the bottom of the script with the field ID of the custom field you created in the first step.
    <script type="text/javascript">// <![CDATA[ setTimeout(function(){ function getUrlParameter(parameterName) { var queryString = document.URL; var parameterName = parameterName + "="; if (queryString.length > 0) {
    var begin = queryString.indexOf(parameterName);
    if (begin != -1) {
    begin += parameterName.length;
    var end = queryString.indexOf( "&" , begin);
    if (end == -1) {
    end = queryString.length
    }
    return unescape(queryString.substring(begin, end));
    }
    }
    return null;
    }
    
    var Url = getUrlParameter("field_id");
    if(Url != null) {
    top.location=Url;
    } else {
    top.location="%%field_id%%";
    }},200);
    // ]]></script>
    
  4. In your iframe URL on your site, add ?field_id=redirect_url where field_id is your custom field’s ID and redirect_url is the URL redirect location that you want to send the prospect to upon completion.