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
)
]%%