0

I am pretty new to marketing cloud and HTML, but I created an HTML form and am trying to host it on a landing page/cloudpage. My problem now is with collecting the responses from the survey. I was searching online and it seemed like PHP was the way to do it, but others mentioned AMPscript. I don't know any PHP and I'm not sure if it is installed on the Marketing Cloud, but this is what my sample code looks like:

The form action:

<form method="post" name="Customer Satisfaction" action="survey.php">

My slightly edited php template code:

<?php
if(isset($_POST['submit'])){
echo $_POST['fullName'];
echo $_POST['company'];
echo $_POST['email'];
echo $_POST['sex'];
echo $_POST['rating'];
echo $_POST['explain'];
}
?>

My question:

How exactly do I link the HTML form action to PHP or AMPscript in order to save the responses into the Marketing Cloud?

I did not include the entire HTML code because I figured it would be unnecessary, but just for reference:

The PHP code contains all the form questions (i.e. fullName, company, email, etc.), which include inputs for text areas, radio buttons, and text. There is a submit button at the end.

Any help is always appreciated. Thank you.

1

You can just redirect the form to another CloudPage which shows confirmation to the user but also has Ampscript code which saves the input into Marketing Cloud. Here is an example with simple HTML.

<form action="%%=RedirectTo(CloudPagesURL(pageID,'radAnswer',RequestParameter('radAnswer'), 
'otherText',RequestParameter('otherText')))=%%" id="myForm" method="post">
 <p style="margin-left: 70px">
  <input name="radAnswer" type="radio" value="One"> One<br>
  <br>
  <input name="radAnswer" type="radio" value="Two"> Two <br>
  <br>
  <input name="radAnswer" type="radio" value="Other"> Other. Please specify: 
  <input name="otherText" type="text"><br>
 </p>
 <p style="margin-left: 40px">
  <input type="submit" value="Submit">
 </p>
</form>

"pageID" is the ID of the CloudPage you are redirecting to

In the redirected CloudPage you can retrieve them as follows

set @radio = QueryParameter('radAnswer')
set @text = QueryParameter('otherText')

Once you have these values, you can use Update Data or Upsert Data to add/update the data to your Data Extension in Marketing Cloud.

3
  • works great, thanks a lot!
    – Intern
    Jun 18 '19 at 19:41
  • is the best/only way to store these responses through a data extension?
    – Intern
    Jun 18 '19 at 19:58
  • In Marketing Cloud, its best to store data in data extension. But since you have data, you can pretty do anything that you can do with Ampscript. I've appended this data to Sales Cloud objects too for example. Ampscript Guide is one of my fav go to guide for Ampscript
    – Pradhyoth
    Jun 18 '19 at 20:33
1

The easiest way to push data to Data Extensions from Cloud Pages is using Smart Capture.

It is entirely a drag and drop configuration, where you select the Data Extension to which your data should be posted, and the form fields will automatically be created and reference the Data Extension fields.

Another advantage of using Smart Capture, is the ability to instantly trigger a journey in Journey Builder, based on the submitted data.

Not the answer you're looking for? Browse other questions tagged or ask your own question.