Smart Capture allows you to easily create forms on your Cloud Pages to collect information about your subscribers and then use that data for future sends and campaigns. While creating a Smart Capture form doesn’t require any coding skills and can be done using only the drag-and-drop editor, adding a simple script to your form can significantly increase the user experience. Forms prepopulated with data can be used for any type of campaign, as long as you already have some data about your subscriber in your database. Subscribers are more likely to register for an event or a raffle when they don’t need to manually fill in all the form fields, and the only thing they have to do is to submit the form.
Create a SmartCapture form
The first thing you will have to do is to create a Smart Capture form on your Cloud Page. Depending on your requirements, you can either create your own Data Extension to collect data submitted by your subscribers or use the system Data Extension called CloudPages_DataExtension.
For the purpose of this tutorial, let’s use the system data extension and create a very simple form with three fields: First Name, Last Name and Email Address.
Add AMPscript to retrieve Salesforce data
In this example, we will be retrieving Sales Cloud data to prepopulate the form using the RetrieveSalesforceObjects function. We will be looking up Contacts in Sales Cloud based on the Subscriber Key. Add the following code in a separate content area, above your Smart Capture form:
If you’re using Campaigns in Sales Cloud, which can admit both Contacts and Leads, you can extend your code with a Substring function, so that it’s able to correctly process both:
You can also use data stored in Marketing Cloud to prefill the form – just remember, that you will need to use the LookupRows function instead of RetrieveSalesforceObjects.
Prepopulate the data in the form
In order to add the data retrieved from Salesforce to your form, you will have to modify each of the form input fields separately. Click once on the Smart Capture form, and then once again on the field you wish to modify.
Now edit the field in the HTML view and add an inline display of the adequate field retrieved from Sales Cloud as the default value at the end of the HTML input tag:
Do this for all the fields that should be prepopulated with data. Publish your CloudPage and test it – the fastest way to test the form is to create an email with a button leading to your CloudPage and previewing the email against a subscriber, who is present in your Salesforce database.
You can also connect this form to a journey in Journey Builder to send a confirmation email to anyone who filled it in, update their Salesforce data or add them to a consecutive campaign.
Read more here about Using a Smart Capture Form as a Journey Builder Entry Event.
14 thoughts on “Create a SmartCapture form prefilled (prepopulated) with Salesforce data”
This article was very helpful.Can you help explain if Cloudpages can be embedded in an external website?
Hi Saksh! You could use iframe to embed a CloudPage in an external website: https://www.w3schools.com/tags/tag_iframe.asp – this however sometimes proves to be buggy. A better solution, would be to use DEManager, which will allow you to pass information from external forms to your Marketing Cloud Data Extensions: https://help.salesforce.com/articleView?id=mc_es_demanager.htm&type=5
Could you please explain how can i retrieve the information customers are filling in the phone field bedore it goes to the CloudPage DE ?
Cause i need to delete the leading 0 and adding ‘33’.
Hi Trailblazer and thank you for your comment! This should be possible, but would require advanced development. If you’re up for it, Ivan’s article would be a good start: https://ampscript.xyz/how-tos/how-to-enhance-your-forms-with-ajax-and-ampscript/. If this, however, would be too difficult for you to implement, you could look into manipulating the data using SQL, after it has been upserted into the CloudPages Data Extension. Another possibility, is to create your own form, which would allow you to modify the data to your needs before upserting it into a Data Extension.
Hi, thank you so much for your article. It has helped me immensely to prepopulate several fields. Unfortunately, I am stuck at the account/company field. Can you please advise how do I code this field? Thank you.
Thank you so much for this article. I have problem pre populating the account field. Can you please give me some advice? Thank you.
Thanks for this article Zuzanna, very helpful! Do you an example with radio button options pulling from one field?
Hi Sharon – Thank you for your question. What is it exactly that you’re trying to achieve? It’s not quite clear to me what you mean by radio button options pulling from one field. Thanks!
Thanks Zuzanna, I’ve worked it out via ampscript. There are 4 different options to pick from that will populate one field and the field gets updated with the new option upon submission 🙂
Thank you for this article, do you know of any connector/solution that would help us in suggesting the address based on the user initial input on the Address field?
Say per example I have a field named address in the form – As soon as the user try to fill the address like 415 Mission…………. the field need to get a auto suggestion like below
“415 Mission Street Third Floor San Francisco, CA 94105 USA ”
Thanks for detailed explanation. I tested this myself and it works perfectly. However, I am using the contact Id as a subscriber key and would like to pre fill it as a hidden attribute. I have tried several different ways but it does not seem to work for me. How would you recommended I can go about achieving this?
Hi Ken, you’d have to first set a @contactId variable in AMPscript and then pass it as a hidden attribute in the SmartCapture form, eg. %%=v(@contactId)=%%
It worked, Thanks!