With URL Parameter Single Input fields, it is possible to configure a Form so that, when embedded or linked to from different contexts, it will redirect to different URLs.
For an introduction to using URL Parameter fields to pass URL parameter values into Forms, see our URL Parameter Form Field article.
Step 1: Add a URL Parameter Field to your Form
In the Form Designer, add a new URL Parameter type Single Input field and set the Field Name to "clk_redirect".
Step 2: Add Dynamic External Links
In the Form Complete section of the Form Designer, add a new Dynamic External Link. Put one of the URLs you want the Form to redirect to into the URL field, and set the expression to "{clk_redirect} = 'landingPage1'".
In this example, "landingPage1" is the URL Parameter value that will cause the Form to redirect to the specified Dynamic External Link URL (https://www.clickdimensions.com). You can of course use whichever parameter value you choose.
Next, add additional Dynamic external links for the other URLs that you want the Form to redirect to. Set the expressions for these Dynamic external links to check for unique URL Parameter values, such as "landingPage2", "landingPage3", etc.
Step 3: Populate Your Form's Links and Embed Codes with URL Parameter Values
Now that you've set up your URL Parameter field and have added the necessary Dynamic External Links, the last step is to ensure that your Form's links and/or embed codes are updated with the relevant URL Parameter values in the appropriate locations: links, iFrame and widget embed codes.
Remember, using the example above, there are two Dynamic external links set with relevant URL parameter values:
- URL parameter value 'landingPage1' will cause the page to redirect to http://www.clickdimensions.com
- URL parameter value 'landingPage2' will cause the page to redirect to https://www.support.clickdimensions.com
How you specify the URL parameter values in each real use case varies by embed method.
Setting URL Parameter Value in a Direct Link
If you are sharing a direct link to the Form, you specify the URL parameter within the URL, like so:
https://youraccount.clickdimensions.com/clickdimensionscom-akpfs/pages/gltzkydjefgrdncopzupsg.html?PageId=[PageID]&clk_redirect=customUrlParameterValue
Note that the URL Parameter's field name is highlighted in yellow, and the custom parameter value is in green.
Using the example values from this article, replacing customURLParameterValue with 'landingPage1' will cause the Form to redirect to http://www.clickdimensions.com while replacing it with 'landingPage2' will cause the Form to redirect to https://www.support.clickdimensions.com.
You can replace it with your own values to cause it to redirect to the desired page.
Setting URL Parameter Value in an iFrame
When using an iFrame to embed your Form, you must specify the URL Parameter field values in the iFrame embed code's src URL:
<iframe src="https://youraccount.clickdimensions.com/clickdimensionscom-akpfs/pages/gltzkydjefgrdncopzupsg.html?clk_redirect=customURLParameterValue" allowtransparency="true" width="100%" height="500px" type="text/html" frameborder="0" style="border:0"></iframe>
In the example above, note that the URL Parameter's field name is highlighted in yellow, and the custom parameter value is in green.
Opening a web page containing Form iFrame embed code configured in this way will populate the URL Parameter field with Field Name "clk_redirect" with the value "customURLParameterValue".
Using the example values from this article, replacing customURLParameterValue with 'landingPage1' will cause the Form to redirect to http://www.clickdimensions.com while replacing it with 'landingPage2' will cause the Form to redirect to https://www.support.clickdimensions.com.
You can replace it with your own values to cause it to redirect to the desired page.
Setting URL Parameter Value in a Widget
When using a widget to embed your Form, you must specify the URL Parameter field values in the widget embed code. This one takes a bit more modification than the iFrame and URL approaches. Your original, unmodified widget embed code will look something like this:
<script type="text/javascript">var loc = "https://yourAccount.clickdimensions.com/clickdimensionscom-akpfs/pages/";var cdSurveyCdn = "https://cdn-preprod.clickdimensions.com/web/newformeditor/";</script>
<script type="text/javascript" src="https://cdn-preprod.clickdimensions.com/web/newformeditor/CDWidget.js"></script>
<div pageID="gltzkydjefgrdncopzupsg"></div>
To specify the URL Parameter field values in the widget embed code, you must modify it by adding an additional script (blue), and modifying it with the Page ID from your original widget embed script (pink) and with URL Parameter field names (yellow) and values (green), as shown below:
<script type="text/javascript">var loc = "https://webanalyticspreprod.clickdimensions.com/clickdimensionscom-akpfs/pages/";var cdSurveyCdn = "https://cdn-preprod.clickdimensions.com/web/newformeditor/";</script>
<script type="text/javascript" src="https://cdn-preprod.clickdimensions.com/web/newformeditor/CDWidget.js"></script>
<div pageID="gltzkydjefgrdncopzupsg"></div>
<script type="application/json" data-cd-widget-config>
{
"pageId": "gltzkydjefgrdncopzupsg",
"urlParams": {
"clk_redirect": "customURLParameterValue"
}
}
</script>
Opening a web page containing the a widget script that has been expanded as shown above will populate the URL Parameter fields with field names "clk_redirect" with the value "customURLParameterValue". Replacing customURLParameterValue with "landingPage1" will cause the Form to redirect to http://www.clickdimensions.com while replacing it with 'landingPage2' will cause the Form to redirect to https://www.support.clickdimensions.com.
You can replace it with your own values to cause it to redirect to the desired page.