Skip to main content
added additional section
Source Link
Eliot Harper
  • 16.7k
  • 9
  • 64
  • 143

Update

Pragyanshu added an additional question (in a comment to my answer) related to capturing the subscribers' email address on the form. This is easily achieved thanks to the CloudPagesURL() function. I've provided the additional steps below.

1. Email Link

Firstly, in your email use the CloudPagesURL() function to define the link to the survey CloudPage:

%%[
var @survey
Set @survey = CloudPagesURL(925)
]%%

<a href="%%=RedirectTo(@survey)=%%">view survey</a>

Where 925 is the ID of your CloudPage. You can retrieve the ID of the CloudPage from the page properties panel:

This will link to the published CloudPage URL and also includes an encrypted parameter referencing the subscriber key and email address of the Subscriber who is receiving the email (really handy!)

2. Survey page

Next, add a hidden form field anywhere within the form area on your survey page (after the opening form tag and before the closing </form> tag) which looks like this:

<input type="hidden" name="email" value="%%emailaddr%%">

The Subscriber email address will be populated in this field based on the encrypted URL parameter.

3. Data Extension

Add a new email address field to your survey Data Extension named email (if it doesn't already exist)

4. Update the AMPscript block on the survey page:

%%[
var @q5_overallHow5, @q6_didOur6, @email

set @q5_overallHow5 = RequestParameter('q5_overallHow5')
set @q6_didOur6 = RequestParameter('q6_didOur6')
set @email = RequestParameter('email')

InsertData("SurveyResults",
           "q5_overallHow5",@q5_overallHow5,
           "q6_didOur6",@q6_didOur6,
           "email",@email
          )
]%%

Update

Pragyanshu added an additional question (in a comment to my answer) related to capturing the subscribers' email address on the form. This is easily achieved thanks to the CloudPagesURL() function. I've provided the additional steps below.

1. Email Link

Firstly, in your email use the CloudPagesURL() function to define the link to the survey CloudPage:

%%[
var @survey
Set @survey = CloudPagesURL(925)
]%%

<a href="%%=RedirectTo(@survey)=%%">view survey</a>

Where 925 is the ID of your CloudPage. You can retrieve the ID of the CloudPage from the page properties panel:

This will link to the published CloudPage URL and also includes an encrypted parameter referencing the subscriber key and email address of the Subscriber who is receiving the email (really handy!)

2. Survey page

Next, add a hidden form field anywhere within the form area on your survey page (after the opening form tag and before the closing </form> tag) which looks like this:

<input type="hidden" name="email" value="%%emailaddr%%">

The Subscriber email address will be populated in this field based on the encrypted URL parameter.

3. Data Extension

Add a new email address field to your survey Data Extension named email (if it doesn't already exist)

4. Update the AMPscript block on the survey page:

%%[
var @q5_overallHow5, @q6_didOur6, @email

set @q5_overallHow5 = RequestParameter('q5_overallHow5')
set @q6_didOur6 = RequestParameter('q6_didOur6')
set @email = RequestParameter('email')

InsertData("SurveyResults",
           "q5_overallHow5",@q5_overallHow5,
           "q6_didOur6",@q6_didOur6,
           "email",@email
          )
]%%
deleted 680 characters in body; added 2 characters in body
Source Link
Eliot Harper
  • 16.7k
  • 9
  • 64
  • 143

There are a few different approaches to achieve this that I've used before, including:

  • AJAX request to a code resource
  • posting form to itself
  • posting form to a thank you page

For simplicity and given your level of experience with AMPscript, I'd recommend you post the form to a thank you page, which I see that are already doing.

I've setup a thank you page which takes the first two fields from your form and inserts them to a Data Extension, which you can review here.

You can use your existing survey page without any changes, but I would suggest making a modification to the action URL, from:

action="http://pub.s7.exacttarget.com/qsv4vnizgda"

to:

action="%%=CloudPagesURL(925)=%%"

Where 925 is the ID of your thank you page. To retrieve this value, open the collections page in CloudPages, click on the page properties icon of the thank you page and make a note of the Page ID in the left column:

It doesn't matter much if you continue to use your hardcoded URL, but this can be helpful if the URL was to ever change.

Now, let's get back to your form.

Firstly, create a DE to contain your form fields. I've created a DE named "SurveyResults" with fields that match your form field names, e.g. q5_overallHow5, q6_didOur6, etc. Make sure these fields in your DE are nullable (as you do not appear to have any required form fields on your form).

Next, update the example that I have provided, to declare and set the variables for each form field (which I've named the same as the form field names, for simplicity), then add these name and variable pairs to the InsertData function in my sample code:

%%[
var @q5_overallHow5, @q6_didOur6

set @q5_overallHow5 = RequestParameter('q5_overallHow5')
set @q6_didOur6 = RequestParameter('q6_didOur6')

InsertData("SurveyResults",
           "q5_overallHow5",@q5_overallHow5,
           "q6_didOur6",@q6_didOur6
          )
]%%

When the form is submitted, the thank you page retrieves the form parameters and uses the InsertData() AMPscript function to insert the values into the DE.

There are a few different approaches to achieve this that I've used before, including:

  • AJAX request to a code resource
  • posting form to itself
  • posting form to a thank you page

For simplicity and given your level of experience with AMPscript, I'd recommend you post the form to a thank you page, which I see that are already doing.

I've setup a thank you page which takes the first two fields from your form and inserts them to a Data Extension, which you can review here.

You can use your existing survey page without any changes, but I would suggest making a modification to the action URL, from:

action="http://pub.s7.exacttarget.com/qsv4vnizgda"

to:

action="%%=CloudPagesURL(925)=%%"

Where 925 is the ID of your thank you page. To retrieve this value, open the collections page in CloudPages, click on the page properties icon of the thank you page and make a note of the Page ID in the left column:

It doesn't matter much if you continue to use your hardcoded URL, but this can be helpful if the URL was to ever change.

Now, let's get back to your form.

Firstly, create DE to contain your form fields. I've created a DE named "SurveyResults" with fields that match your form field names, e.g. q5_overallHow5, q6_didOur6, etc. Make sure these fields in your DE are nullable (as you do not appear to have any required form fields on your form).

Next, update the example that I have provided, to declare and set the variables for each form field (which I've named the same as the form field names, for simplicity), then add these name and variable pairs to the InsertData function in my sample code:

%%[
var @q5_overallHow5, @q6_didOur6

set @q5_overallHow5 = RequestParameter('q5_overallHow5')
set @q6_didOur6 = RequestParameter('q6_didOur6')

InsertData("SurveyResults",
           "q5_overallHow5",@q5_overallHow5,
           "q6_didOur6",@q6_didOur6
          )
]%%

When the form is submitted, the thank you page retrieves the form parameters and uses the InsertData() AMPscript function to insert the values into the DE.

There are a few different approaches to achieve this that I've used before, including:

  • AJAX request to a code resource
  • posting form to itself
  • posting form to a thank you page

For simplicity and given your level of experience with AMPscript, I'd recommend you post the form to a thank you page, which I see that are already doing.

I've setup a thank you page which takes the first two fields from your form and inserts them to a Data Extension, which you can review here.

Firstly, create a DE to contain your form fields. I've created a DE named "SurveyResults" with fields that match your form field names, e.g. q5_overallHow5, q6_didOur6, etc. Make sure these fields in your DE are nullable (as you do not appear to have any required form fields on your form).

Next, update the example that I have provided, to declare and set the variables for each form field (which I've named the same as the form field names, for simplicity), then add these name and variable pairs to the InsertData function in my sample code:

%%[
var @q5_overallHow5, @q6_didOur6

set @q5_overallHow5 = RequestParameter('q5_overallHow5')
set @q6_didOur6 = RequestParameter('q6_didOur6')

InsertData("SurveyResults",
           "q5_overallHow5",@q5_overallHow5,
           "q6_didOur6",@q6_didOur6
          )
]%%

When the form is submitted, the thank you page retrieves the form parameters and uses the InsertData() AMPscript function to insert the values into the DE.

added 4 characters in body
Source Link
Eliot Harper
  • 16.7k
  • 9
  • 64
  • 143

There are a few different approaches to achieve this that I've used before, including:

  • AJAX request to a code resource
  • posting form to itself
  • posting form to a thank you page

For simplicity and given your level of experience with AMPscript, I'd recommend you post the form to a thank you page, which I see that are already doing.

I've setup a thank you page which takes the first two fields from your form and inserts them to a Data Extension, which you can review here.

You can use your existing survey page without any changes, but I would suggest making a modification to the action URL, from:

action="http://pub.s7.exacttarget.com/qsv4vnizgda"

to:

action="%%=CloudPagesURL(925)=%%"

Where 925 is the ID of your thank you page. To retrieve this value, open the collections page in CloudPages, click on the page properties icon of the thank you page and make a note of the Page ID in the left column:

It doesn't matter much if you continue to use your hardcoded URL, but this can be helpful if the URL was to ever change.

Now, let's get back to your form.

Firstly, create DE to contain your form fields. I've created a DE named "SurveyResults" with fields that match your form field names, e.g. q5_overallHow5, q6_didOur6, etc. Make sure these fields in your DE are nullable (as you do not appear to have any required form fields on your form).

Next, update the example that I have provided, to declare and set the variables for each form field (which I've named the same as the form field names, for simplicity), then add these name and variable pairs to the InsertData function in my sample code:

%%[
var @q5_overallHow5, @q6_didOur6

set @q5_overallHow5 = RequestParameter('q5_overallHow5')
set @q6_didOur6 = RequestParameter('q6_didOur6')

InsertData("SurveyResults",
           "q5_overallHow5",@q5_overallHow5,
           "q6_didOur6",@q6_didOur6
          )
]%%

When the form is submitted, the thank you page retrieves the form parameters and uses the InsertData() AMPscript function to insert the values into the DE.

There are a few different approaches to achieve this that I've used before, including:

  • AJAX request to a code resource
  • posting form to itself
  • posting form to a thank you page

For simplicity and given your level of experience with AMPscript, I'd recommend you post the form to a thank you page, which I see that are already doing.

I've setup a thank you page which takes the first two fields from your form and inserts them to a Data Extension, which you can review here.

You can use your existing survey page without any changes, but I would suggest making a modification to the action URL, from:

action="http://pub.s7.exacttarget.com/qsv4vnizgda"

to:

action="%%=CloudPagesURL(925)=%%"

Where 925 is the ID of your thank you page. To retrieve this value, open the collections page in CloudPages, click on the page properties icon of the thank you page and make a note of the Page ID in the left column:

It doesn't matter much if you continue to your hardcoded URL, but this can be helpful if the URL was to ever change.

Now, let's get back to your form.

Firstly, create DE to contain your form fields. I've created a DE named "SurveyResults" with fields that match your form field names, e.g. q5_overallHow5, q6_didOur6, etc. Make sure these fields in your DE are nullable (as you do not appear to have any required form fields on your form).

Next, update the example that I have provided, to declare and set the variables for each form field (which I've named the same as the form field names, for simplicity), then add these name and variable pairs to the InsertData function in my sample code:

%%[
var @q5_overallHow5, @q6_didOur6

set @q5_overallHow5 = RequestParameter('q5_overallHow5')
set @q6_didOur6 = RequestParameter('q6_didOur6')

InsertData("SurveyResults",
           "q5_overallHow5",@q5_overallHow5,
           "q6_didOur6",@q6_didOur6
          )
]%%

When the form is submitted, the thank you page retrieves the form parameters and uses the InsertData() AMPscript function to insert the values into the DE.

There are a few different approaches to achieve this that I've used before, including:

  • AJAX request to a code resource
  • posting form to itself
  • posting form to a thank you page

For simplicity and given your level of experience with AMPscript, I'd recommend you post the form to a thank you page, which I see that are already doing.

I've setup a thank you page which takes the first two fields from your form and inserts them to a Data Extension, which you can review here.

You can use your existing survey page without any changes, but I would suggest making a modification to the action URL, from:

action="http://pub.s7.exacttarget.com/qsv4vnizgda"

to:

action="%%=CloudPagesURL(925)=%%"

Where 925 is the ID of your thank you page. To retrieve this value, open the collections page in CloudPages, click on the page properties icon of the thank you page and make a note of the Page ID in the left column:

It doesn't matter much if you continue to use your hardcoded URL, but this can be helpful if the URL was to ever change.

Now, let's get back to your form.

Firstly, create DE to contain your form fields. I've created a DE named "SurveyResults" with fields that match your form field names, e.g. q5_overallHow5, q6_didOur6, etc. Make sure these fields in your DE are nullable (as you do not appear to have any required form fields on your form).

Next, update the example that I have provided, to declare and set the variables for each form field (which I've named the same as the form field names, for simplicity), then add these name and variable pairs to the InsertData function in my sample code:

%%[
var @q5_overallHow5, @q6_didOur6

set @q5_overallHow5 = RequestParameter('q5_overallHow5')
set @q6_didOur6 = RequestParameter('q6_didOur6')

InsertData("SurveyResults",
           "q5_overallHow5",@q5_overallHow5,
           "q6_didOur6",@q6_didOur6
          )
]%%

When the form is submitted, the thank you page retrieves the form parameters and uses the InsertData() AMPscript function to insert the values into the DE.

Source Link
Eliot Harper
  • 16.7k
  • 9
  • 64
  • 143
Loading