Generate Leads with Salesforce Sites

Lead Generation

One of the first steps in the sale cycle of any business is generating leads. In the prospecting stage, you have to ensure that your clients can easily contact you when you gain their interest. If your company has a strong web presence, or if you are advertising online, a good web form is key to generating leads. If your company also uses a CRM like Salesforce you need a proper integration between the two.

You can pull lead data to your Salesforce account in a number of ways. Most of them include using 3rd party software to integrate your website with your CRM.

If you know what you are doing, this could be the most optimal way in terms of time needed to set it up. But keep in mind that any 3rd party software will require additional costs depending on the complexity of the integration and the amount of data that will be sent between.

That’s why Salesforce offers a different approach.

You can generate leads directly from a web form into your system. No integrations, no 3rd party solutions, and in some cases you won’t even need an actual website.

In this article, we'll focus on creating a web form with a Salesforce Site,  but let’s look at all the different ways to generate leads directly into Salesforce.

If you want to get straight to the point, here's a table of contents so you can jump to the topic that interests you.

Table of Contents

  1. Lead Generation
  2. Web-to-Lead
  3. LinkedIn Lead Gen Ads
  4. Salesforce Sites
  5. Create the Web Form
  6. Build your objects
  7. Introduction to Flows
  8. Flow Builder
  9. Create the Flow
  10. Create and Configure a Salesforce Site
  11. Introduction to Salesforce Sites
  12. Create a Visualforce Page
  13. Sites’ Limitations, Usage and Billing
  14. Register a Domain
  15. Configure the Required Settings for a New Site
  16. The Guest User Profile
  17. Enhance Your Form
  18. Common Issues
  19. Conclusion


The easiest, and least complex method to capture prospecting data is Web-to-Lead.

  1. Just type “web-to-lead” in the Quick Find box in Setup.
  2. Pick which fields to include.
  3. Specify who should be listed as Creator when Lead is created.
  4. Decide the URL to direct users after they complete the form.
  5. Configure the reCAPTCHA widget (if you want to).
  6. Copy the generated HTML code to your website.

And voila, your new web form is ready to use. Quick and easy.

From now on, each new lead is automatically generated in your Salesforce org.

Well, at least the first 500 leads each day are. The rest of the data is sent in an email to the Default Lead Creator. That’s because 500 leads is the daily limit.

It’s also important to remember that if any field values are invalid (due to validation rules in place), no lead record is created. For the full list of limitations and considerations, visit this page.

This method works only if you have a working website (which you probably have).

But the real biggest limitation of Web-to-Lead might be that it’s exactly what it claims to be, and nothing more.

This means you can’t go beyond creating leads. If you use custom objects, or want to store the information in another standard object, you will need additional automations on the Salesforce side to segment the data.

But it doesn’t change the fact that Web-to-Lead is still a great way to collect leads from simple web forms. It is quick and easy to configure. In most cases, it will do the job.

LinkedIn Lead Gen Ads

A form on the company website isn’t the only way to generate leads. There are many marketing and social platforms that enable you to run advertisements and collect prospecting data directly from them.

One of the biggest and most popular is LinkedIn. If your services are aimed at professionals, LinkedIn is probably one of the best places to advertise B2B services.

Salesforce offers a native solution to connect your LinkedIn account to your CRM. Just like with Web-to-Lead the process is very straightforward, and doesn’t require a developer to help you out.

Just be mindful that this integration works with LinkedIn Lead Gen ads specifically.

This solution is useful for those that prefer to advertise directly on LinkedIn, rather than direct customers to their company page.

Salesforce Sites

Simplicity is great and all, but there are times when you need your prospects to fill out more than just a couple of text fields. Because the more information you gather, the more qualified your leads are going to be.

Salesforce offers a way to create elaborate forms directly in Salesforce, and let external users fill them out without logging into your system.

You don’t need to ask your web developer to help you with building a complex web form for this (although you might need his help). What’s more, you don’t even need a website.

We can use standard Salesforce tools to create the form, and publish it on the site.

But this is just a high level overview. Let’s break it down into manageable pieces with step-by-step instructions to guide you through the process.

Just a word of warning, this is more than just picking fields. We will be customizing objects and fields, using Salesforce tools for automation, creating a Visualforce page (yes, a bit of coding) and configuring security options.

Create the Web Form

Build your objects

Our first step is to prepare the system to store all the information we need. You will need to ask yourself if you want to collect every detail in the Lead or break the data into more objects.

Or you might even decide to skip the Lead altogether and go straight for custom objects.

The decision is yours. If you decide to break the data into separate objects, you will have to work on additional automations. On the other hand, it’s going to be easier to manage that data later on. Having all information combined into one object is a quick way to clutter your system.

Introduction to Flows

If you are a Salesforce administrator, you should be familiar with Workflow or Process Builder. These two tools allow you to automate most basic tasks, such as populating fields, changing record owners or posting to chatter.

But Salesforce offers one more tool to automate staff, often overlooked by administrators because it uses a code-like logic. This tool is Flow Builder.

It gives administrators the ability to create complex processes without the need to know how to code. By using variables to store data, and actions that can look up/create/delete any record in the system, you can build really powerful automations.

But the real reason why Flows can be so useful in lead generation is that Flow Builder allows you to create screen flows that can guide users through processes. The idea is simple - you display fields to your users to collect information and then use that data for various actions, such as creating a new record.

Sounds familiar? Yup, that’s exactly what web forms do!

For today’s exercise, let’s create a simple form to collect personal information from a user. And to demonstrate how Flows can help you create more complex automations, we will give them an option to pick a product from the existing ones in Salesforce.

On the site note: I don’t recommend using standard Products if your Flows are to be available to external users. This is one of few objects that’s very tightly connected to others, and have quite a lot of limitations.

We are going to create all that in a Playground - a developer edition available for free on Trailhead. The reason for this is that there are already example Products created in any Playground.

We aren’t going to create any additional fields for our form. The standard fields in a Lead are enough to collect basic personal details, and the little information about products we will be asking for. We can go straight to creating a Flow.

Note: If you are familiar with Flows, you can skip the next part. We’ll be creating a simple contact form - but I tend to explain other staff as well, so if you are familiar with Flows, but don’t mind learning something new, you should probably keep reading.

Flow Builder

Go to Setup, and search for Flows. Click “New Flow” in the upper right-hand corner to start the Flow Builder.

Here you choose what kind of Flow you want to create. There are lots of options:

You can build record-triggered flows that work like Process Builder automations, but can look up unrelated objects.
Autolaunched flows are similar but launch when invoked by a different process, Apex, and more.
You can even create schedule-triggered flows. They are great to automate manual tasks that need to be done on a frequent basis, like checking records.

As you can see, a lot can be done with Flows. If you want to learn more about them, check our article that describes all the reasons for using Flow Builder.

In our case, we are going to build a Screen Flow. But before we start doing that, we’ve got one more decision to make - whether we want to use Freeform or Auto-Layout. When we create flows we drag and drop elements onto canvas, and connect them to create paths. The latter mode does all the positioning for us, which may sound handy, but building flows often comes with modifying existing paths, testing and debugging - having more freedom makes those tasks easier.

For instance, in Auto-Layout mode, you can’t have screens floating separately from other elements. But having an additional screen on the side, which displays values from variables can be very useful when you need to test your process. Freeform mode allows you to keep that screen separated from the others, so you can connect it in case you want to make sure the values are correct.

In other words, I recommend the Freeform mode. Also, you can switch between those two modes anytime while working on a Flow so… let’s get started.

If this is your first time seeing Flow Builder - here’s a quick introduction:

The menu on the left-hand side is where you can see elements available for your Flow:
actions that do something with records - creating, editing them, etc,
interactions, which include: screens that display some output to users and let them interact with your flow, actions, such as email sends, and subflows,
logic elements that let you configure how the flow works

You also have a couple of smaller buttons in the left-upper hand corner that let you copy elements, as well as undo whatever you just did. Keep them in mind because they really help save time.

The buttons at the bottom of the canvas let you zoom in, zoom out, fit to canvas, and drag to select.

You can actually use the select and copy options together to quickly duplicate a portion of your flow.

Create a Flow

Now that you have the basic knowledge of the Flow Builder, drag and drop the Screen element onto the canvas. This will be the start screen.

First of all, you should know that the header title, which is the Flow’s name, will be visible on each screen unless you uncheck an option for that under a section labeled “Configure Frame”.

While you’re browsing through screen properties, you should also uncheck “Previous” and “Pause” from the Control Navigation.

Now, drag and drop the “Display Text” component from the menu on the left. This will serve as the header for this screen, so name it appropriately.

Now, depending on the information we want to collect from the end user, we need to add correct input fields.

Personal details like name or title should obviously be text fields. For other input types, such as Email, Phone or Address, you can use specific components. They automatically format the data and have a built-in validation. But this also means that if you require a very specific validation, a simple text or number field will be easier to configure since they allow you to create your own formula for validation.

Remember that our example form will be used for collecting web leads from a public page.
This is important, because if your flow encounters an error at any of the steps, it will stop and display an error message. And we really don’t want that to happen.

We’ll use standard components for Email and Phone this time, but keep that in mind.

Now, for the last field, let’s give the end user an option to choose a product they are interested in. Drag and drop a picklist field onto the screen.

Click on the blank field for Choice, and click “New Resource”. Pick “Record Choice Set” as the type. This resource type enables us to create a picklist out of existing records. Choose Product (Product2) as the object. We won’t be using any filters. Pick the Name as the choice label and as the choice value. This way, any time a user picks a product, our flow will save its name.

Our Start Screen is ready. Let’s save this flow, so we can try debugging it and see how it looks from the perspective on an end user.

Debugging is one of the most convenient features of Flows. It enables you to test run your flow and understand what exactly happens at each step. As you can see below, the fields are rendered properly, and our picklist correctly displays products.

Now, we need to take the information we collected and create a new Lead in the system.

Drag and drop the “Create Records” element onto the canvas.

The configuration here is very straightforward. Just remember to check “Use separate resources, and literal values”. This way you can pick a value for each field you want to populate.

Because we don’t have a field that’s suitable for the product, we are using the standard description to store the product’s name. We are also populating the Company field with “NA” because it’s required. The flow would fail otherwise.

You should also decide who should be the record owner. By default, it’s going to be you - the admin that’s configured the flow.

One last thing we need to do is to create a simple finish screen which displays the thank you message after successful form submission.

With all that set up, our Flow is ready.

Let’s debug it one more time, this time by inputting some test data and check if everything goes smoothly (remember to save the flow first).

If it does, activate the Flow.

And with this, our form is ready. Now, we need a way to make it available for external users.

Create and Configure a Salesforce Site

What are Salesforce Sites

There are basically two ways you can allow someone who isn’t in your organization to view or create data in your CRM directly - with Communities or Sites.

If you follow any Salesforce news, the first term might be familiar. Salesforce describes Communities as branded spaces for your employees, customers and partners to connect. You can create a brand-new service or use one of the pre-built templates to easily create a Help Center, a Customer Service Portal or even a Partner Central. For the full information on templates click here.

Communities are great if you are looking for a robust solution. But all we have is a simple form to collect leads. Building a Community for this sounds like an overkill.

Fortunately, there are also Sites - another tool to bring Salesforce content to customers.

With Sites, you can create public websites and applications that are directly integrated with your Salesforce organization - without requiring users to log in. This means you don’t need to perform any type of API integration between your site and organization.

There are multiple ways you can use Sites: to create a support FAQ, a catalog of products, a public community forum, or a web form to generate leads.

Create a Visualforce Page

Sites are built on Visualforce pages. This means that we need to create a Visualforce page, brand it to look similar to our company website, and render the flow we’ve created in the previous step on that Visualforce page.

This part might seem a bit overwhelming if you’ve never had any experience in coding, but don’t worry. All we need to do is to get our form to work on the Site. And this can be done by copy-pasting a ready-to-use template. We can leave the styling to the developer.

But firstly, we need to create a lightning application. Go to Developer Console, click “File”, then “New”, and choose “Lightning Application”.

Replace the default code with the code below:

<aura:application access="global" extends="ltng:outApp" implements="ltng:allowGuestAccess" ><aura:dependency resource="lightning:flow"/></aura:application>

With this, our flow will render in Lightning runtime and allow guest users to access it.

Now, create the Visualforce page (the same way you did with the Lightning Application).

Replace the default code with the code below:

<apex:page >
<apex:includeLightning />
<div id="flowContainer" />
$Lightning.use("c:lightningOutApp", function() {
// Create the flow component
$Lightning.createComponent("lightning:flow", {},
function (component) {
// Start the interview in the flowContainer div

Now, replace the lightningOutApp (in the line starting with $Lightning.use) with the name of your lightning app that you’ve just created, so the line reads: $Lightning.use("c:mylightningapp", function() {

Next, replace the “myFlowName” with the API name of your flow.

And voila, the visualforce page is ready. You can preview how it looks by clicking on the button in the upper left-hand corner of the Developer Console.

Sites’ Limitations, Usage and Billing

Your visualforce page is working and you are eager to publish it on the Site, but before we do that, let’s take a look at some very crucial information regarding Sites - usage and billing.

The usage of Salesforce sites is governed by monthly and daily allocations. Depending on your Salesforce Edition there are different limits for maximum number of sites, bandwidth allocation, service request time and maximum page views.

Here’s a summary of usage limits from Salesforce’s official documentation.

Maximum Number of Sites
Developer Edition: 1
Enterprise Edition: 25
Unlimited Edition/Performance Edition: 25

Bandwidth Allocation (per rolling 24-hour period per site)
Developer Edition: 500 MB
Enterprise Edition: 1 GB for sandbox and 40 GB for production
Unlimited Edition/Performance Edition: 1 GB for sandbox and 40 GB for production

Service Request Time (per rolling 24-hour period per site)
Developer Edition: 10 minutes
Enterprise Edition: 30 minutes for sandbox and 60 hours for production
Unlimited Edition/Performance Edition: 30 minutes for sandbox and 60 hours for production

Maximum Page Views
Developer Edition: N/A
Enterprise Edition: 500,000
Unlimited Edition/Performance Edition: 1,000,000

This means that monitoring your Sites should become your daily habit to avoid hitting the governor limits.

Another important factor in deciding how to build your Sites should be the matter of access and authentication. This is something we haven’t talked about yet, but guest users can’t have full access to your CRM data the way standard Salesforce users have.

You can grant “Read” and “Create” permissions on all standard objects except products, price books, and ideas; and “Read”, “Create”, “Edit”, and “Delete” on all custom objects.

Register a Domain

Now that the visualforce page is ready, we know what we can work with in terms of limitations, it’s time to build an actual Salesforce Site.

Search “Sites” in Setup.

You will be welcomed by a short introduction to what Sites are and will be asked to register your Salesforce site domain. This is important because all your Sites will be available under that domain. So don’t go with whatever comes to your mind but try to use your brand or company name.

It might be difficult if you have different entities under one umbrella, or multiple brands. That’s why Salesforce allows you to register your own branded domain or subdomain to redirect to your Site.

After registering a domain, you can create a new Salesforce Site.

Configure the Required Settings for a New Site

There are a lot of settings that can be configured. Let’s look at the ones that are required.

Site Label - the name of the site as it appears in the user interface.

Site Name - the API name of the site

Site Contact - the user responsible for receiving site-related communications from site visitors and

Default Record Owner - the default owner has access to all new records that guest users create.

Active Site Home Page - here you pick the Visualforce page we’ve created for our form.

Clickjack Protection Level - specifies the type of framing allowed. If same origin framing is selected, site pages can only be framed by the other pages on the same domain name and protocol security (HTTP or HTTPS). You can leave the recommended option.

Also, Default Web Address - this is not required, but if you plan on having multiple Sites, each is going to need a unique URL.

After filling out all that, your Site is ready. If you haven’t checked “Active”, you can activate, or deactivate it in the Site Details section. You can also click edit to change whatever needs to be changed.

Click on the URL of your Site to see how it looks. If you followed all the steps, it should look something like that:

You’ll probably want to ask a developer to style this a little bit.

But that’s their job. It’s ours to make sure that our form is working properly. Even at first glance you can notice that something is not right. The product picklist isn’t showing any products at all. But that’s expected because we haven’t configured the guest user profile yet.

The Guest User Profile

Whenever you create a Site, a guest user profile for that site is also created. Every person that visits the page is treated as the guest user. For them to be able to create and read the objects with our flow, the guest users need to be granted specific permissions. Just like any other user in your Salesforce organization.

The guest user profile is labeled the same as your Site, and you can find it by going to your Site’s settings and clicking the “Public Access Settings” in the Site Detail section.

Now, let’s think hard about what kind of permissions our guest users must have for the whole process to work. We don’t want to give them any more access than we need to. Really. This is a matter of security. The fact that we allow external users to create records is something that you should discuss with your developers, higher ups and whoever else needs to know before activating the site. Especially when it’s going to involve showing them records existing in the system, namely, products.

Firstly, our guest users will be using flow to create leads and populate certain fields: First Name, Last Name, Email, Mobile, and Description. In other words, we need to grant them access to Create Leads (Standard Object Permission section), and to those five fields (Field-Level Security). See below where to find those settings.

We are displaying a list of Products, so we need to also give guest users permission to Read products.

Now, go to Site once again. This time, the picklist should include all products. Try submitting a test form. And done. Your web form is ready.

But this doesn’t mean your work is over. Now, you should style it so it resembles your actual website. Also, if needed, set up the URL redirect.

Here’s how the form can look after a quick update of stylesheets:

web form with styling

You also need to remember about monitoring your Site’s usage. You don’t want to wake up one day seeing “In Maintenance” instead of your form.

Enhance Your Form

I mentioned multiple times that Flows can be used to build powerful automations. I’m sure that you will find a lot of ways to incorporate other solutions into them.

If the standard screen components aren’t enough to cover your needs, you can try AppExchange.

Also, check our blog for more articles on Flows.

Common Issues

Here are some common issues that you might encounter when setting up Sites with Flows.

CANNOT INSERT UPDATE ACTIVATE ENTITY - This type of flow error usually means that your guest user is missing some sort of permissions to create a record. It may be followed by: entity type cannot be inserted: Lead

Double check their profile to make sure they are granted access to all objects created in the process.

INSUFFICIENT ACCESS ON CROSS REFERENCE ENTITY - This is something that took me a while to figure out. If your flow populates any master-detail field, make sure it’s set to “Read only” instead of “Read/Write” in the object manager. This error could also happen when your user’s CRED (Create/Read/Edit/Delete) permissions are insufficient.

Another issue that you could run into is while looking up records and read fields. This happens when you don’t set up sharing settings for guest users. Like any other user in your Salesforce organization, the guest user needs to have access to records that are looked up in Flows. To specify who can see what, you need to set up sharing settings.

How to do it? Go to “Sharing Settings” from Setup. Create a new rule for the object in question, choose a guest user access as your rule type, set some general criteria, pick the right guest user profile, and save it. You can’t give more access than “Read Only”.


The process of building Flows, publishing Sites and configuring security settings is a complicated one.

But at the same time, it’s a great way to create complex solutions that any administrator with minimal coding knowledge can modify later on. With Flows you can build product catalogues, real estate applications, insurance quotes, and many other tools that can help you grow your revenue.

If it seems overwhelming, or you need help, our team at Tech Gravel will be more than happy to give you a hand. Contact us here! Or reach out to us on LinkedIn.