Salesforce
Sourcream writes each lead's first and last source, medium and campaign into custom fields on Salesforce Leads and Contacts, through the Salesforce REST API. Salesforce does not let an app create custom fields without a metadata deployment, so your Salesforce admin creates the fields once (about 15 minutes), and Sourcream fills them from then on.
Before you start
- Edition: API access is needed. Enterprise, Unlimited, Performance and Developer editions include it; Professional Edition only with Salesforce's API add-on.
- Production orgs: Sourcream connects through
login.salesforce.com. Sandboxes are not supported yet. - The Sourcream app: your Salesforce admin installs the Sourcream connected app package in your org once. Email [email protected] and we send the current install link.
- The connecting user needs the API Enabled permission and edit access to Leads and Contacts. Use a dedicated integration user if you have one, so changes are easy to identify in field history.
1. Create the fields
Create each field on Lead and on Contact with exactly these API names (Setup, Object Manager, Lead or Contact, Fields & Relationships, New). Labels are up to you; typing the label in the first column makes Salesforce generate the right Field Name.
| Sourcream value | Field label | API name | Type |
|---|---|---|---|
| first_source | Sourcream First Source | Sourcream_First_Source__c |
Text (255) |
| first_medium | Sourcream First Medium | Sourcream_First_Medium__c |
Text (255) |
| first_campaign | Sourcream First Campaign | Sourcream_First_Campaign__c |
Text (255) |
| last_source | Sourcream Last Source | Sourcream_Last_Source__c |
Text (255) |
| last_medium | Sourcream Last Medium | Sourcream_Last_Medium__c |
Text (255) |
| last_campaign | Sourcream Last Campaign | Sourcream_Last_Campaign__c |
Text (255) |
| sc_visitor_id | Sourcream Visitor ID | Sourcream_Visitor_ID__c |
Text (255), tick External ID |
| first_term | Sourcream First Term | Sourcream_First_Term__c |
Text (255) |
| first_content | Sourcream First Content | Sourcream_First_Content__c |
Text (255) |
| first_channel | Sourcream First Channel | Sourcream_First_Channel__c |
Text (255) |
| first_landing_page | Sourcream First Landing Page | Sourcream_First_Landing_Page__c |
Text Area (Long), length 1,000 |
| first_referrer | Sourcream First Referrer | Sourcream_First_Referrer__c |
Text Area (Long), length 1,000 |
| first_timestamp | Sourcream First Timestamp | Sourcream_First_Timestamp__c |
Text (255) |
| last_term | Sourcream Last Term | Sourcream_Last_Term__c |
Text (255) |
| last_content | Sourcream Last Content | Sourcream_Last_Content__c |
Text (255) |
| last_channel | Sourcream Last Channel | Sourcream_Last_Channel__c |
Text (255) |
| last_landing_page | Sourcream Last Landing Page | Sourcream_Last_Landing_Page__c |
Text Area (Long), length 1,000 |
| last_referrer | Sourcream Last Referrer | Sourcream_Last_Referrer__c |
Text Area (Long), length 1,000 |
| last_timestamp | Sourcream Last Timestamp | Sourcream_Last_Timestamp__c |
Text (255) |
| gclid | Sourcream GCLID | Sourcream_GCLID__c |
Text (255) |
| gbraid | Sourcream GBRAID | Sourcream_GBRAID__c |
Text (255) |
| wbraid | Sourcream WBRAID | Sourcream_WBRAID__c |
Text (255) |
| msclkid | Sourcream MSCLKID | Sourcream_MSCLKID__c |
Text (255) |
| fbclid | Sourcream FBCLID | Sourcream_FBCLID__c |
Text (255) |
| ttclid | Sourcream TTCLID | Sourcream_TTCLID__c |
Text (255) |
| li_fat_id | Sourcream LI FAT ID | Sourcream_LI_FAT_ID__c |
Text (255) |
| touch_count | Sourcream Touch Count | Sourcream_Touch_Count__c |
Text (255) |
The first seven are the core set, sent on every plan; create at least those. The rest are sent when the integration's Field set is Extended (Business plan and above). Timestamps are ISO 8601 text in UTC, for example 2026-10-10T01:02:03.000Z. On Pro and Agency plans, the integration's Field mapping can point any value at a different field API name instead, for example a field you already have.
For each field:
- On the field level security step, make it visible (and not read only) for the profile of the user who will connect Sourcream. A field that user cannot see does not exist as far as the API is concerned, and Sourcream reports it as missing.
- Adding it to page layouts is optional.
Then map the Lead fields to the Contact fields so values carry over when a lead converts: Object Manager, Lead, Fields & Relationships, Map Lead Fields, and pick each Sourcream_...__c contact field.
2. Connect
- In Sourcream, open Integrations and choose Connect on Salesforce.
- Log in to Salesforce as the connecting user and allow access. Sourcream asks for the
apiandrefresh_tokenscopes (OAuth with PKCE) and stores your instance address. - Back in Sourcream, Setup runs: it reads the Lead and Contact field lists and reports which Sourcream fields exist and which are missing. Fix any missing fields and press Setup again. Sourcream also rechecks fields at least once a day.
3. How leads are written
Choose under the integration's settings:
- Salesforce object: Auto (default). Sourcream looks for an unconverted Lead with the lead's email, then a Contact with that email, and updates the match. With Create when missing on, it creates a Lead: last name from the name (or "[not provided]"), company (or "[not provided]"), and the standard Lead Source set to the last touch source.
- Lead or Contact only: match and create on that object alone.
- Match by visitor ID instead of email: Sourcream finds the record whose
Sourcream_Visitor_ID__cequals the lead's visitor ID, retrying every 5 minutes for up to 24 hours while the record does not exist yet. Your form has to deliversc_visitor_idinto Salesforce for this to work (below).
Only fields that exist on the object are written. First touch fields are only written when empty (turn on Overwrite first touch to change that); last touch fields, click ids and the visitor ID are written with every lead.
If your Lead Source picklist is restricted, values such as google or linkedin are rejected when Sourcream creates a lead. Either add the values you expect, or leave the picklist unrestricted.
4. Web-to-Lead forms
Salesforce Web-to-Lead names custom field inputs by field id (for example 00N5g00000AbCdE), not by API name. To have the Sourcream script fill them:
- Generate the Web-to-Lead HTML with the Sourcream fields included and copy each field id from it.
- In Sourcream, set the site's Field names so each value uses its id:
first_sourceto00N5g00000AbCdE, and so on, includingsc_visitor_idfor the visitor ID field.
The values then reach Salesforce with the Web-to-Lead submission itself, and Match by visitor ID works without Sourcream handling the email at all.
5. Test
Use the integration's Send test lead button: it writes a lead for [email protected] ("Sourcream Test", first touch google / cpc / test, last touch facebook / cpc / test). Delete it afterwards. The Deliveries log shows each delivery, its status and any Salesforce error message.
Common errors:
INVALID_FIELDor a field listed as missing: field level security hides it from the connecting user, or the API name differs.STRING_TOO_LONG: a landing page or referrer field was created as Text (255); change it to Text Area (Long).INVALID_SESSION_IDthat does not clear after a retry: the connection was revoked or the user deactivated. Reconnect from Integrations.
Disconnecting
Remove the integration in Sourcream to stop deliveries. The fields and their values stay in Salesforce. Your admin can also revoke Sourcream under the connected user's OAuth connected apps.
Questions: [email protected]