Posting data through the redirect URL

redirect-url.png

When users submit your form, you have the option to send them to a custom confirmation page via the Form Settings’ redirect URL option. In order to pass data from the form to the confirmation page, Cognito Forms supports parameterized redirect URLs.

Creating parameterized redirect URLs

To start using this feature, first you will need a URL that is going to be receiving the information from the form. This URL will be called the ‘base URL’ and should include the protocol, server name, and resource id.

Example: http://www.example.com

To add parameters, at the end of the base URL, you will need to add a question mark (?) after the last character of the base URL.

Example: http://www.example.com?

Each parameter contains two parts, a Key and a Token that is separated by an equal sign (=). The Key will be used to assign the field value outside of the form. The Key can be named anything that fits your needs. The Token must be named the same your field’s label in your form and must be contained inside brackets [ ].

Key=[Token]

As an example, if you have a name field on your form labeled “Name”, the parameter will look like this:

Name=[Name]

Please notice in this example, Name is being used for both the Key and the Token. Although this is helpful, you do not need to have the Key named the same as the Token. The following is also acceptable as long as the Key matches your value outside of the form:

YourName=[Name]

Your redirect URL would like this:

http://www.example.com?YourName=[Name]

Additional parameters can be added by separating each parameter using an Ampersand (&). Adding an Address to the example above would look like this, if your field’s label is ‘Address’ on your form:

http://www.example.com?YourName=[Name]&YourAddress=[Address]

Field types

Some field types require more specific token values:

Sections

First, include the field label followed by a period (.), and then add the Label of the field. Example: Key=[SectionLabel.FieldLabel]

Rating scales

For a Rating Scale question labeled Question1, the parameter would be: RatingScale=[RatingScale.Question1]

The URL example from before will now look like:

http://www.example.com?RatingScale=[RatingScale.Question1]

Name fields

To target only the First Name of a Name field use Name=[Name.First] and to target the Last Name use Name=[Name.Last]. For example, if you only want to collect the First Name and not the Last Name: http://www.example.com?YourName=[Name.First]

Address fields

The different Tokens for the Address are: Line1, Line2, City, State, PostalCode. For example: http://www.example.com?Address=[Address.Line1]

Troubleshooting tips

  • The fields that can be used as parameters within a Redirect URL are: Name, Textbox, Address, Choice, Date/Time, Email, Number, Website, Currency, Rating Scale, Section, and Calculation.The following fields cannot be used as parameters: Content, Repeating Section, and File Upload.
  • There is no limit to the number of fields that can be used as redirect URL parameters; however, most modern browsers only allow for URLs to be 2000 characters long.
    An example would be to collect only the first line of an address field: http://www.example.com?Address=[Address.Line1]
  • The form ID is not a field on the form but you can capture and display the ID through a redirect URL so that users will have a reference number. The token for a form id is [Id]. For example: http://www.example.com?ID=[Id]
  • Once you’ve passed the data through the URL, you can use a PHP $_GET function to capture the data and include it on your custom confirmation page. For example: Thank you for your submission, [First.Name]!