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.