If you’re using Leads and Contacts in Salesforce it can be a bit hard to track all people at the Account level – there’s no native matching of Leads to Accounts in Salesforce. Implementing Lead to Account matching in Salesforce is pretty easy, though – here are the steps:
First, create a ‘domain’ formula field on Account that ‘cleans’ any value in the website field to just return a ‘clean domain’ – the formula looks like this:
SUBSTITUTE(
IF(
FIND(“/”,
IF(
FIND(“www.”, Website) > 0,
IF(
FIND(“//”, Website) > 0,
SUBSTITUTE(
Website,
LEFT(
Website,
FIND(“//www.”, Website) + 5),
NULL
),
Website
),
IF(
FIND(“//”, Website) > 0,
SUBSTITUTE(
Website,
LEFT(
Website,
FIND(“//”, Website) + 1),
NULL),
Website
)
)
) > 0,
LEFT(
IF(
FIND(“www.”,Website)>0,
IF(
FIND(“//”,Website)>0,
SUBSTITUTE(
Website,
LEFT(
Website,
FIND(“//www.”,Website) + 5
),
NULL),
Website
),
IF(
FIND(“//”,Website)>0,
SUBSTITUTE(
Website,
LEFT(
Website,
FIND(“//”,Website) + 1
),
NULL
),
Website
)
),
FIND(“/”,
IF(
FIND(“www.”,Website)>0,
IF(
FIND(“//”,Website)>0,
SUBSTITUTE(
Website,
LEFT(
Website,
FIND(“//www.”, Website) + 5
),
NULL
),
Website),
IF(
FIND(“//”,Website) > 0,
SUBSTITUTE(
Website,
LEFT(
Website,
FIND(“//”,Website) + 1
),
NULL
),
Website
)
)
) -1
),
IF(
FIND(“www.”,Website)>0,
IF(
FIND(“//”,Website)>0,
SUBSTITUTE(
Website,
LEFT(
Website,
FIND(“//www.”,Website)+5),
NULL
),
Website
),
IF(
FIND(“//”,Website)>0,
SUBSTITUTE(
Website,
LEFT(
Website,
FIND(
“//”,
Website) + 1
),
NULL
),
Website)
)
),
‘www.’,
”
)
So your formula field looks like this:
This is an important field – it’s what we’ll use to match Leads to Accounts and it can be used to identify duplicate Accounts since this field strips out values like ‘http’ and ‘https’ to only return a ‘clean domain’ (i.e. salesforce.com not http://salesforce.com).
Next, create a very similar field on Leads – but use the email address to create a ‘clean domain’ field instead of website. This will also be a text formula field that looks like this:
SUBSTITUTE(Email, LEFT(Email, FIND(“@”, Email)), NULL)
And the actual field looks like this:
We’ll use the domain field on Leads to match to the domain field on Accounts. We’ll add an additional field on Leads: a Lookup to Account. This is the field we’ll populate with the Account ID when we find a match based on the two domain fields. This is a simple lookup to Account field that looks like this:
Finally, we’ll create a flow that on Lead Create – if the Lead has an Email Address – then match the Lead’s Domain to an Account Domain and if a matching Account is found, set this new Account field on the Lead. Create a Flow that triggers on Leads (I typically just do on Lead Create). The first step in this Flow is to Get Account Records that match the Lead’s Domain:
Next, add a decision step to check if an Account record was found or not:
If an Account was found, use the values from this record to set the Account field on the Lead:
(in the above screen-shot, I also set the Company Name so that Company Names are consistent everywhere). After that, just update the Lead with the new values. If I need to backfill to match Leads to Accounts for all records in the Salesforce, I typically do this offline via Dataloader following the same logic: export all Leads with domain, export all Accounts with Domain and Account ID, match Accounts to Leads on domain then bulk update to set the Account field on Leads.
Matching Leads to Accounts in Salesforce is valuable for many reasons and it ensures when looking at an Account in Salesforce you’ll see all ‘people’ related to that Account, not just Contacts.