Sub topic 12
Reporting on Lead Conversion
This chapter assumes you have read the earlier chapters on lead conversion and lead status. It also assumes you can build a basic summary report in Salesforce and run a SOQL query in the Developer Console. The chapter covers how Salesforce records conversion on the lead, which report types expose that data, how to calculate a conversion rate, and how to query the same data with SOQL and Apex.
What conversion leaves behind
Converting a lead does not delete it. The lead record stays in the database, becomes read-only, and no longer appears in standard lead list views. Salesforce stores the result of the conversion in fields on the lead:
| Field (API name) | What it holds |
|---|---|
| `IsConverted` | Checkbox. True once the lead has been converted. |
| `ConvertedDate` | The date the conversion happened. |
| `Status` | The converted Lead Status value chosen during conversion. |
| `ConvertedAccountId` | The account that was created or updated. |
| `ConvertedContactId` | The contact that was created or updated. |
| `ConvertedOpportunityId` | The opportunity that was created. Empty if the user chose not to create one. |
These fields are the basis for all lead conversion reporting. Three points follow from them:
- A report on "leads" can include both open and converted leads. You decide which by filtering on the Converted field.
- You can reach the downstream account, contact, and opportunity from a converted lead, but not the other way round. An opportunity record has no direct link back to its source lead except through these lead fields.
ConvertedOpportunityIdis often empty. Any "leads that became pipeline" metric must handle that case.
Choosing a report type
Two standard report types matter here.
| Report type | Use it for |
|---|---|
| Leads | Counting leads by source, status, owner, or created date, with or without converted leads. Good for funnel volume. |
| Leads with converted lead information | Showing lead fields next to fields from the converted account, contact, and opportunity. Good for questions such as "which lead sources produced the largest opportunities?" |
Use the simpler Leads type when you only need lead fields. Use the converted-information type only when you need fields from the converted records. It also lets you include fields such as the opportunity stage and amount.
Filter on Converted explicitly
Always set the Converted filter yourself instead of relying on a default. A report with no filter on it mixes open and converted leads, which makes counts such as "open leads by owner" wrong. Use these settings:
- Converted = False for pipeline-of-leads reports, such as open leads per owner or per queue.
- Converted = True for reports about what conversion produced.
- No filter, grouped by Converted, for reports that compare converted and unconverted leads.
Building a conversion count report
A basic report of conversions by lead source works as follows:
- Create a report with the type Leads.
- Set the date filter on Converted Date, with a range such as This Quarter.
- Add the filter Converted equals True.
- Group rows by Lead Source.
- Add a chart, such as a horizontal bar, based on Record Count.
This report answers "how many leads converted this quarter, by source". It does not answer "what percentage of leads converted". For that you also need the leads that did not convert, and a way to divide.
Calculating a conversion rate
A conversion rate is converted leads divided by total leads. Report builders count rows, so the usual technique is to turn each lead into a number: 1 if converted, 0 if not. The average of those numbers is the rate.
Create a number formula field on Lead, for example Converted_Flag__c, with this formula:
IF(IsConverted, 1, 0)Set the formula type to Number with 0 decimal places. Then build a summary report on Leads:
- Leave the Converted filter off, so both converted and unconverted leads are included.
- Group by Lead Source.
- Summarize
Converted_Flag__cwith Average and give the column a percent label.
Each group's average equals converted leads divided by all leads in that group. Format the summary as a percentage.
Cohort and period rates answer different questions
The date filter you choose changes what the rate means:
| Date filter | Meaning | Typical use |
|---|---|---|
| Created Date | Of the leads created in the period, how many have converted so far (a cohort rate). | Comparing campaigns or sources fairly. |
| Converted Date | How many conversions happened in the period, whatever month the leads were created in. | Measuring team activity and output. |
A cohort rate for a recent period will look low because many of those leads have not had time to convert yet. Compare cohorts of the same age, such as "leads created in January, measured on March 31", with other cohorts measured at the same age. Do not compare last week's cohort with last year's.
Time to convert
Conversion speed is often more useful than the rate. Salesforce does not provide a ready-made field for it, but you can calculate it from CreatedDate and ConvertedDate. A number formula field on Lead gives you a value that reports can average:
IF(IsConverted, ConvertedDate - DATEVALUE(CreatedDate), null)Name it Days_To_Convert__c. It is empty for unconverted leads, so averages only include converted ones. Group a report by Lead Source or Lead Owner and summarize the field with Average to see which sources produce fast conversions.
For a breakdown of where leads spend time before conversion, enable field history tracking on Lead Status. History tracking starts only when you turn it on, so older leads have no history.
Querying conversion data with SOQL
Reports are the best tool for ad hoc analysis. SOQL is better when you need the data in code, in an integration, or in a script. The simplest query lists the most recent conversions and the records they created:
SELECT Id, Name, ConvertedDate, ConvertedAccountId, ConvertedContactId, ConvertedOpportunityId
FROM Lead
WHERE IsConverted = true
ORDER BY ConvertedDate DESC
LIMIT 10You can also follow the converted relationships to read fields from the opportunity in the same query:
SELECT Id, LeadSource, ConvertedOpportunity.StageName, ConvertedOpportunity.Amount
FROM Lead
WHERE IsConverted = true AND ConvertedOpportunityId != nullThe relationship names are ConvertedAccount, ConvertedContact, and ConvertedOpportunity. The ConvertedOpportunityId != null filter drops conversions that did not create an opportunity.
A conversion rate by source in Apex
SOQL has no conditional count, so group by both source and IsConverted, then divide in code. Run this in the Developer Console as anonymous Apex:
Map<String, Integer> totals = new Map<String, Integer>();
Map<String, Integer> converted = new Map<String, Integer>();
for (AggregateResult ar : [
SELECT LeadSource src, IsConverted conv, COUNT(Id) cnt
FROM Lead
GROUP BY LeadSource, IsConverted
]) {
String src = (String) ar.get('src');
if (src == null) {
src = '(no source)';
}
Integer cnt = (Integer) ar.get('cnt');
Boolean isConv = (Boolean) ar.get('conv');
Integer soFar = totals.containsKey(src) ? totals.get(src) : 0;
totals.put(src, soFar + cnt);
if (isConv) {
Integer convSoFar = converted.containsKey(src) ? converted.get(src) : 0;
converted.put(src, convSoFar + cnt);
}
}
for (String src : totals.keySet()) {
Integer total = totals.get(src);
Integer conv = converted.containsKey(src) ? converted.get(src) : 0;
Decimal rate = (Decimal.valueOf(conv) / total * 100).setScale(1);
System.debug(src + ': ' + conv + ' of ' + total + ' converted (' + rate + '%)');
}The (no source) bucket is a data-quality signal. A large one means users are creating leads without a Lead Source, and every source-based report will under-count.
Days to convert in Apex
The same fields give you conversion time per lead:
for (Lead l : [
SELECT Id, CreatedDate, ConvertedDate
FROM Lead
WHERE IsConverted = true
ORDER BY ConvertedDate DESC
LIMIT 20
]) {
Integer days = l.CreatedDate.date().daysBetween(l.ConvertedDate);
System.debug(l.Id + ' converted after ' + days + ' days');
}Common reporting problems
- Converted leads missing from a report. The report has a Converted = False filter, or it is based on a custom report type that excludes converted leads. Check the filters first.
- Opportunity fields blank. The lead was converted without an opportunity. Filter on
ConvertedOpportunityId != nullor the report equivalent. - Deleted leads skew the rate. Leads deleted as junk disappear from the denominator, so the rate looks higher than the true figure. Mark junk leads with a status such as Disqualified instead of deleting them, and decide whether to exclude that status from the rate.
- Owner shows a queue. Leads still sitting in a queue are owned by the queue, so "Lead Owner" groups can contain queue names. For converted leads, the owner reflects who owned the lead at that point, which is not necessarily the person who converted it.
- Rate differs between reports. Check whether each report filters on Created Date or Converted Date. The two give different numbers by design.
- Source-based reports show little. Lead Source was not populated. Make it required through a validation rule or on Web-to-Lead forms with a hidden field.
Practical guidance
- Define "conversion rate" once, in writing, including the date field and the status values that count as disqualified. Put the definition in the dashboard description.
- Build one report for volume (record counts) and one for rate (the formula flag average). Mixing them in one chart makes both harder to read.
- Use dashboards with filters on Lead Source and Owner so one report serves several teams.
- Test your numbers against a SOQL query once. If the report and the query agree, you can trust the report from then on.
Exercise
Your manager wants the conversion rate for leads created in October, grouped by Lead Source. Which date field should the report filter on, what should the Converted filter be, and how do you get a percentage out of a report that only counts rows?
Show answer
Filter on Created Date (October), so the group is a cohort of leads created in that month. Leave the Converted filter off (or include both values), because the denominator must include unconverted leads. Add a number formula field such as IF(IsConverted, 1, 0), group by Lead Source, and summarize the field with Average. The average is the converted leads divided by all leads in each group. Format it as a percentage.
Exercise
A SOQL query for leads with ConvertedOpportunity.Amount returns fewer rows than SELECT COUNT() FROM Lead WHERE IsConverted = true. Why, and how do you confirm it?
Show answer
Some leads were converted without creating an opportunity, so ConvertedOpportunityId is empty and the query that filters on it excludes them. To confirm, run SELECT COUNT() FROM Lead WHERE IsConverted = true AND ConvertedOpportunityId = null and check that the two counts add up.