Skip to main content

Salesforce integration

Send quiz takers to Salesforce as leads, or update their contact, with their answers, a quiz activity and an optional campaign for your Flows.

Written by Traian

With the Salesforce integration, quiz takers who leave their email are added to Salesforce as leads, or update their contact if they're already a customer of yours. Each completion also adds an activity with their answers, their recommended products and a link to their results, so your team sees what every customer told the quiz.

The integration works with Salesforce editions that include API access, like Enterprise, Unlimited and Developer, or Professional with the API add-on.

Step 1: Create an app for Lantern in Salesforce

Salesforce doesn't use API keys. Instead, you create a small app in Salesforce Setup that gives Lantern a Consumer Key and a Consumer Secret. You need to be a Salesforce admin to create it.

1.1 In Salesforce, click the gear icon at the top right and open Setup. Type External Client App Manager in the Quick Find box, open it and click New External Client App.

1.2 Fill in the basics:

  • External Client App Name: a name you'll recognize, like Lantern.

  • Contact Email: your email.

  • Distribution State: Local.

1.3 Under API (Enable OAuth Settings), tick Enable OAuth and set:

  • Callback URL: https://login.salesforce.com/services/oauth2/success. Salesforce requires one, but Lantern never uses it.

  • OAuth Scopes: select Manage user data via APIs (api) and click the arrow to move it into Selected OAuth Scopes.

  • Flow Enablement: tick Enable Client Credentials Flow.

Leave the other settings as they are and click Create.

1.4 On the new app, open the Policies tab and click Edit. Open OAuth Policies, tick Enable Client Credentials Flow and fill in Run As (Username) with the Salesforce user Lantern should act as. Leads, activities and campaign members that Lantern creates are saved as this user, so pick an admin or a user who can create leads. Click Save.

The Run As field needs the user's exact Salesforce username, which is often not their login email. You'll find it in Setup under Users, in the Username column.

1.5 Open the Settings tab, then OAuth Settings, and click Consumer Key and Secret. Salesforce emails you a verification code. Enter it, then copy the Consumer Key and the Consumer Secret.

A new app can take up to 10 minutes before Salesforce accepts it, so if Lantern says the key is invalid right away, wait a few minutes and try again.

Step 2: Connect Salesforce in Lantern

2.1 In Lantern, open Integrations, find Salesforce under Marketing and click Connect.

Image showing the Salesforce card on Lantern's Integrations page with the Connect button.

2.2 Fill in the window:

  • Salesforce address: your My Domain URL, like https://yourcompany.my.salesforce.com. You can also paste the address from your browser's address bar while you're in Salesforce, and Lantern turns it into the right one.

  • Consumer Key and Consumer Secret: the two values from step 1.5.

  • Campaign (optional): the name or ID of a Salesforce campaign. Quiz takers are added to it as campaign members (see Campaigns and Flows below). Leave it empty if you don't need one.

Image showing the Salesforce window in Lantern with the Salesforce address, Consumer Key, Consumer Secret and Campaign fields filled in.

2.3 Click Connect. Lantern checks the app with Salesforce, and the card shows Connected. If something's wrong, the window says what to fix, for example a missing Run As user or a campaign name that doesn't exist.

Image showing the Salesforce card on Lantern's Integrations page with the Connected badge and the Edit button.

Once connected, every active quiz in your store sends quiz takers to Salesforce, with no settings to change per quiz.

What Salesforce receives

When a customer completes a quiz and leaves their email, either on the Optin Page or in the Email sign-up on the Results page, Lantern looks the email up in Salesforce:

  • If a contact has that email, Lantern updates the contact.

  • If not, but an open lead has it, Lantern updates the lead.

  • Otherwise, Lantern creates a new lead with the email, the name and phone from the Optin Page, and the Lead Source Lantern quiz.

Salesforce requires a Last Name and a Company on every lead. When the quiz doesn't ask for a last name, Lantern writes [not provided], and Company is always [not provided], the same placeholder Salesforce's own web-to-lead forms use. If the customer takes the quiz again with their last name, the real name replaces the placeholder. Lantern never creates contacts and never converts leads.

Every completion also adds a completed activity to the lead or contact, called Completed Lantern quiz followed by the quiz name. It lists every question with the customer's answer, the products the quiz recommended and a link to their results page. You'll find it in the record's Activity timeline. A customer who takes the quiz twice gets two activities, one per completion.

Saving answers in Salesforce fields

The activity holds every answer with no setup. If you'd also like answers in their own fields, for reports, list views or Flows, create the fields in Salesforce. Lantern fills fields that exist and never creates fields in your Salesforce.

Lantern matches fields by Question Property ID, a short name for a question's answer that you set in the question's right-hand panel in the quiz editor. You can read more about Property IDs in How to use customer answers in Lantern quizzes. A question with the Property ID skin_type fills the field whose API name is Skin_Type__c, or a field labeled skin_type. Capital letters don't matter, and characters other than letters and numbers count as underscores, so Skin-Type matches Skin_Type__c too.

To create a field:

  • In Setup, open Object Manager, then Lead, then Fields & Relationships, and click New.

  • Pick a type. Text takes any answer. A Picklist or Multi-Select Picklist only takes answers that match its values exactly, and a multiple choice answer fills a multi-select picklist with each answer as its own value. Number and Checkbox fields only take answers that fit them.

  • Use the Property ID as the Field Label, so Salesforce makes the matching Field Name.

  • On the field-level security step, make the field visible and editable for the profile of your Run As user, or Lantern can't fill it.

  • Create the same field on Contact if you'd like answers saved for people who are already contacts.

When Salesforce refuses a value, for example an answer that isn't one of a picklist's values, Lantern saves the record without that answer and keeps the rest. The answer is still in the activity.

Lantern also fills these fields when you create them, with exactly these labels:

  • Lantern Quiz (Text): the URL handle of the quiz they took, for example skin-care-finder.

  • Lantern Results URL (URL): a link to their results page, so your emails can send them back to their recommendations.

  • Lantern Recommended Products (Long Text Area): the names of the products on their results page, separated by commas.

  • Lantern Completed At (Date/Time): when they completed the quiz. It changes every time, so a Flow can run again when a customer retakes the quiz.

Campaigns and Flows

Salesforce sends follow-up emails through Flows, or through Account Engagement (formerly Pardot) if your account includes it. A few ways to start one from the quiz:

  • A campaign: with a campaign on the Lantern card, every quiz taker becomes a member of it, once. Start a record-triggered Flow when a campaign member is created, or use the campaign in Account Engagement.

  • New leads: start a Flow when a lead is created with the Lead Source Lantern quiz.

  • Every completion: start a Flow when Lantern Completed At changes, so contacts and returning customers are included too.

Inside the Flow, add decisions on the answer fields to send each customer the email that fits their answers. Take the quiz once yourself with your own email to see a lead arrive before you build the Flow.

Marketing consent

Lantern only sends customers who can be emailed:

  • A lead or contact is sent when the customer left an email and Subscribe to email marketing is on for the quiz.

  • Nothing is sent when the customer declined marketing. If your Optin Page shows an optional consent checkbox and the customer leaves it unticked, they aren't sent.

  • Nothing is sent for a customer who left only a phone number, because Lantern finds leads and contacts by email.

The switch is on the Optin Page: open Integration Settings on the right-hand side. It's on by default, and the section appears once Salesforce is connected. Lantern never changes Email Opt Out or any other consent field in Salesforce. To set up the Optin Page and its consent checkbox, see Collect customer emails.

Disconnecting and troubleshooting

To disconnect, open Integrations, click Edit on the Salesforce card and click Disconnect. Lantern stops sending customers. Your leads, contacts and activities stay in Salesforce.

To change the campaign, click Edit on the Salesforce card. The window asks for the Consumer Key and Secret again with every change, because Lantern never shows them back.

If Lantern won't save, the window names the problem:

  • Invalid Consumer Key or Secret: copy both again from step 1.5. A new app can take up to 10 minutes to work.

  • Turn on Enable Client Credentials Flow and set a Run As user: repeat step 1.4.

  • Salesforce refused access: your Salesforce edition doesn't include API access, or the app is missing the api scope from step 1.3.

If customers stop arriving in Salesforce, check that the app still exists, that the Run As user is active, and that the Consumer Secret wasn't regenerated. After a new secret, paste it on the Lantern card and click Update.

Good to know

  • Sensitive answers are not shared. Answers to questions set to Don't share or Don't store are never sent to Salesforce, in fields or in the activity. See How Sensitive Data Controls Work.

  • Test submissions are included. Completing the quiz in Preview with an email adds that person to Salesforce too.

  • Duplicate rules: if your Salesforce duplicate rules block new leads that match an existing one, Salesforce refuses the lead and Lantern can't add it. Rules that only alert don't stop it.

  • Zapier still works. If you'd rather build your own automation, the Zapier integration can also send quiz takers to Salesforce.

Did this answer your question?