Uncategorized

Create a lead into Sales/Service Cloud through an Iframe from your website using AMPscript

The aim of this article is to demonstrate you how to create a lead in Salesforce core when a lead or prospect fills out details from a landing page on your website.

1- Build the HTML form

Let’s kick off by creating a simple HTML form. We will find below the code needed to build the HTML form.

<table style="padding: 20px;"><tr><td>
      <h2>Get started today!</h2>
      <form action="%%=RequestParameter('PAGEURL')=%%" method="post">
      <label>First name: </label><input type="text" name="firstname" required=""><br>
      <label>Last name: </label><input type="text" name="lastname" required=""><br>
      <label>Company: </label><input type="text" name="company" required=""><br>
      <label> Work email: </label><input type="text" name="email" required=""><br>
<label> Country: </label><input type="text" name="email" required=""><br>
         <input name="submitted" type="hidden" value="true"><br>
         <input type="submit" value="Submit">
      </form>  
</td></tr></table>

2- Create a new lead

By improving the code above we will be able to create a new lead into Salesforce.

%%[
IF RequestParameter("submitted") == true THEN
 
 /* create a new lead */
  SET @leadId = CreateSalesforceObject(
        "Lead", 5,
        "FirstName", RequestParameter("firstname"),
        "LastName", RequestParameter("lastname"),
        "Company", RequestParameter("company"),
        "Work Email", RequestParameter("work email"),
        "Country", RequestParameter("country)
       )

/* add lead to a campaign*/  
SET @CampaignMember = CreateSalesforceObject("CampaignMember", 3,
     "CampaignId", "6900t0000009kl1",
     "LeadId", @leadId,
     "Status", "Sent"
      )  

]%% 
 
<table style="padding: 20px;"><tr><td>
      <h2>Get started today!</h2>
      <form action="%%=RequestParameter('PAGEURL')=%%" method="post">
      <label>First name: </label><input type="text" name="firstname" required=""><br>
      <label>Last name: </label><input type="text" name="lastname" required=""><br>
      <label>Company: </label><input type="text" name="company" required=""><br>
      <label> Work email: </label><input type="text" name="work email" required=""><br>
<label> Country: </label><input type="text" name="country" required=""><br>
         <input name="submitted" type="hidden" value="true"><br>
         <input type="submit" value="Submit">
      </form>  
</td></tr></

Note: You have to create your campaign in salesforce then use the Id into the code.

Leave a Reply

Your email address will not be published. Required fields are marked *