How to Create a Data Extension in Marketing Cloud
Step-by-step guide to creating a Data Extension in Salesforce Marketing Cloud — fields, primary keys, sendable settings and retention — with screenshots.
How to insert data into a Marketing Cloud Data Extension using CloudPages and AMPscript — a step-by-step form example with complete, working code.
Welcome in Salesforce Marketing Cloud Worlds. Here i'm starting the Salesforce Marketing Cloud Technical Blog series for beginners, this may helps beginners and intermediate level learners to possess an honest knowledge of Salesforce Marketing Cloud .
Hey Guys, In this post, you will learn how to create a form using HTML and AMPscript and include functions that allow you to quickly insert data into a data extension.
After reading this post you will be able to:
A landing page is a web page that you can view from a browser, or link to in other websites and emails. You can also create custom forms with AMPscript in landing pages.
First of all, we will create a cloud page to save the user's data which will contain many fields.
Under Web Studio> Cloud Page> Create a Collection> Create a Landing Page.
Go to Web Studio > CloudPages > Click on CloudPages
Under Create Collection > Enter Name > Enter Description> Click on Save
Here Collection Name is LearnFrenzy
Mind it!
Here, we will create a landing page with Content Builder Cloudpages.
Step #1: In a collection (Here Collection Name is LearnFrenzy), click Create, then click Landing Page.
Step #2: Under the Create a Landing Page
Here Landing Page Name is Registration Form (Under Collections -"LearnFrenzy")
Step #3: Select a layout and click Create. The editor appears with the Blocks tab selected.
Step #4: Use Content Blocks to create your content.
Step #5: Optional: Use the Layout/Code View toggle to change your editing experience.
Optional: Use the Desktop/Mobile toggle to see how your content looks in each view.
Click Save or Schedule / Publish.
After creation a landing page , we will create a data extension with the same fields as present in the HTML Form.
Create a Data Extension under Email Studio > Email > Subscribers > Data Extensions with the same fields as present in the HTML or as shown below
Here Data Extension Name : WebpageDE
We don’t have to assign a Primary Key, but for the purpose of this example SubscriberKey and/or EmailAddress can be assigned as such.
Mind it!
Refer to How to Create a Data Extension in Marketing Cloud link for more details.
Create a simple responsive HTML landing page in cloud pages under Web Studio > CloudPages as shown below
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<title>Registration Form</title>
</head>
<body>
<form action="%%=RequestParameter('PAGEURL')=%%" method="post">
<div class="row setup-content" id="">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3><strong>Personal Informatiom</strong></h3>
<p>
Please enter your personal details.
</p><br>
<div class="form-group">
<label class="control-label">Email</label>
<input type="email"
required="required"
class="form-control"
placeholder="EMAIL"
id="email"
name="email">
</div>
<div class="form-group">
<label class="control-label">First Name</label>
<input type="text"
required="required"
class="form-control"
placeholder="First Name"
id="firstname"
name="firstname">
</div>
<div class="form-group">
<label class="control-label">Last Name</label>
<input type="text"
required="required"
class="form-control"
placeholder="Last Name"
id="lastname"
name="lastname">
</div>
<div class="form-group">
<label class="control-label">D.O.B</label>
<input type="date" class="form-control" id="date" name="dob">
</div>
<label class="control-label">Gender</label>
<div class="form-group">
<div class="col-sm-3">
<label class="radio-inline">
<input name="gender" id="input-gender-male" value="Male" type="radio" />Male
</label>
</div>
<div class="col-sm-3">
<label class="radio-inline">
<input name="gender" id="input-gender-female" value="Female" type="radio" />Female
</label>
</div><br>
</div>
<div class="form-group">
<label class="control-label">Company Name</label>
<input type="text"
required="required"
class="form-control"
placeholder="Company Name"
id="companyname"
name="companyname">
</div>
<div class="form-group">
<label class="control-label">Proficiency</label>
<input type="text"
required="required"
class="form-control"
placeholder=""
id="proficiency"
name="proficiency">
</div>
<button id="myButton" class="btn btn-success btn-lg pull-left" type="submit">Submit</button>
</div>
</div>
</div>
</form>
</body>
</html>
The form action method attribute specifies how to send form-data. In this case, we are using post, which appends form-data inside the body of the HTTP request (data is not shown is in URL).
The RequestParameter('PAGEURL') function reloads the page when the form is submitted, posting the form parameters back to the same page, which are then retrieved by the RequestParameter() AMPscript functions.
This code gives us an idea of how our form will look like but as you will publish the cloud page and click on the submit button nothing will happen as we are not using any function to insert the data.
Now I use the Insert Data function to insert data into the Salesforce data extension. Check out the code given below.
%%[
InsertData(
"WebpageDE",
"Email",RequestParameter("email"),
"FirstName",RequestParameter("firstname"),
"LastName",RequestParameter("lastname"),
"DOB",RequestParameter("dob"),
"Gender",RequestParameter("gender"),
"CompanyName",RequestParameter("companyname"),
"Proficiency",RequestParameter("proficiency")
)
]%%
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<title>Registration Form</title>
</head>
<body>
<form action="%%=RequestParameter('PAGEURL')=%%" method="post">
<div class="row setup-content" id="">
<div class="col-xs-6 col-md-offset-3">
<div class="col-md-12">
<h3><strong>Personal Informatiom</strong></h3>
<p>
Please enter your personal details.
</p><br>
<div class="form-group">
<label class="control-label">Email</label>
<input type="email"
required="required"
class="form-control"
placeholder="EMAIL"
id="email"
name="email">
</div>
<div class="form-group">
<label class="control-label">First Name</label>
<input type="text"
required="required"
class="form-control"
placeholder="First Name"
id="firstname"
name="firstname">
</div>
<div class="form-group">
<label class="control-label">Last Name</label>
<input type="text"
required="required"
class="form-control"
placeholder="Last Name"
id="lastname"
name="lastname">
</div>
<div class="form-group">
<label class="control-label">D.O.B</label>
<input type="date" class="form-control" id="date" name="dob">
</div>
<label class="control-label">Gender</label>
<div class="form-group">
<div class="col-sm-3">
<label class="radio-inline">
<input name="gender" id="input-gender-male" value="Male" type="radio" />Male
</label>
</div>
<div class="col-sm-3">
<label class="radio-inline">
<input name="gender" id="input-gender-female" value="Female" type="radio" />Female
</label>
</div><br>
</div>
<div class="form-group">
<label class="control-label">Company Name</label>
<input type="text"
required="required"
class="form-control"
placeholder="Company Name"
id="companyname"
name="companyname">
</div>
<div class="form-group">
<label class="control-label">Proficiency</label>
<input type="text"
required="required"
class="form-control"
placeholder=""
id="proficiency"
name="proficiency">
</div>
<button id="myButton" class="btn btn-success btn-lg pull-left" type="submit">Submit</button>
</div>
</div>
</div>
</form>
</body>
</html>
In the above code, data is getting saved into the Salesforce data extension “WebpageDE” whenever a person hits the Submit after populating the fields.
After Submitted the registration form, we can see the one record is added in Data Extension (WebpagE).
Go on and try it in your account.
One short email when we publish something new — interview questions, Salesforce guides and career tips. No spam, unsubscribe in one click.
Step-by-step guide to creating a Data Extension in Salesforce Marketing Cloud — fields, primary keys, sendable settings and retention — with screenshots.
Lists vs Data Extensions in Salesforce Marketing Cloud Email Studio — how each stores subscribers, their limits and when to use which for your campaigns.
Scenario-based Salesforce trigger questions with solutions — real business requirements turned into Apex triggers, with code and explanations.
Questions, corrections or your own experience — they all help the next reader.
Priyanka
Abraham Bravo
Prash
Chai
Kumar
Viku
Vinod
Abhi Ajit
Ankita
Amit
Ruchita