Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 69 additions & 35 deletions models/demo/leads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@ models:
is_admin_saas_demo: 'true'
primary_key: lead_id
ai_hint: |
This is a leads table containing lead information and derived facts.
Use this for lead or sales stage funnel reporting, marketing efficiency analysis, and sdr reporting.
This is a leads table containing lead information and derived facts.
Use this for lead or sales stage funnel reporting, marketing efficiency analysis, and sdr reporting.

joins:
- join: users
sql_on: ${leads.user_id} = ${users.user_id}
type: left
relationship: many-to-one
- join: deals
sql_on: ${leads.deal_id} = ${deals.deal_id}
sql_on: ${leads.deal_id} = ${deals.deal_id}
type: left
relationship: many-to-one

parameters:
utm_toggle:
label: "Lead source toggle"
description: "Group leads by marketing lead source, campaign name, or campaign medium"
description: "Group leads by marketing lead source, campaign name, or campaign
medium"
options:
- "lead_source"
- "utm_medium"
- "campaign_name"
- "lead_source"
- "utm_medium"
- "campaign_name"
default: "lead_source"
multiple: false

Expand All @@ -36,7 +37,7 @@ models:
description: "Percentage of leads that converted"
sql: "(${converted_leads} / NULLIF(${unique_lead_count}, 0))"
format: percent
groups: ['Lead Performance']
groups: [ 'Lead Performance' ]
spotlight:
visibility: show
categories:
Expand All @@ -49,7 +50,7 @@ models:
description: "Average number of days it takes for a lead to convert"
sql: DATE_DIFF(${converted_at}, ${created_at}, DAY)
format: '0.0'
groups: ['Lead Performance']
groups: [ 'Lead Performance' ]
spotlight:
visibility: show
categories:
Expand All @@ -62,7 +63,7 @@ models:
description: "Average cost per converted lead"
sql: SAFE_DIVIDE(${total_lead_cost}, ${converted_leads})
format: '$#,##0.00'
groups: ['Lead Performance']
groups: [ 'Lead Performance' ]
spotlight:
visibility: show
categories:
Expand All @@ -78,7 +79,7 @@ models:
unique_lead_count:
type: count_distinct
description: "The unique number of leads based on distinct lead IDs"
groups: ['Lead Counts']
groups: [ 'Lead Counts' ]
spotlight:
visibility: show
categories:
Expand All @@ -89,18 +90,18 @@ models:
Use this for customer aquisition analysis and lead funnel reporting.
open_leads:
type: count_distinct
groups: ['Lead Counts']
groups: [ 'Lead Counts' ]
description: Count unique leads with status = 'Open'
filters:
- lead_status: ['new', 'contacted', 'qualified']
- lead_status: [ 'new', 'contacted', 'qualified' ]
spotlight:
visibility: show
categories:
- leads
- marketing
contacted_leads:
type: count_distinct
groups: ['Lead Counts']
groups: [ 'Lead Counts' ]
description: Count unique leads with status = 'Contacted'
filters:
- lead_status: 'contacted'
Expand All @@ -111,7 +112,7 @@ models:
- marketing
qualified_leads:
type: count_distinct
groups: ['Lead Counts']
groups: [ 'Lead Counts' ]
description: Count unique leads with status = 'Contacted'
filters:
- lead_status: 'qualified'
Expand All @@ -122,7 +123,7 @@ models:
- marketing
converted_leads:
type: count_distinct
groups: ['Lead Counts']
groups: [ 'Lead Counts' ]
description: Count unique leads with status = 'Converted'
filters:
- lead_status: 'converted'
Expand All @@ -133,7 +134,7 @@ models:
- marketing
disqualified_leads:
type: count_distinct
groups: ['Lead Counts']
groups: [ 'Lead Counts' ]
description: Count unique leads with status = 'Disqulified'
filters:
- lead_status: 'disqualified'
Expand Down Expand Up @@ -166,7 +167,7 @@ models:
unique_deal_count:
type: count_distinct
description: "The unique number of deals"
groups: ['Counts']
groups: [ 'Counts' ]
spotlight:
visibility: show
categories:
Expand All @@ -179,24 +180,28 @@ models:
additional_dimensions:
is_paid_marketing:
type: boolean
sql: IF(LOWER(lead_source) IN ('google ads', 'facebook ads', 'linkedin'), TRUE, FALSE)
sql: IF(LOWER(lead_source) IN ('google ads', 'facebook ads', 'linkedin'), TRUE,
FALSE)
utm_toggle:
label: "Lead source toggle"
description: "Group leads by marketing lead source, campaign name, or campaign medium"
description: "Group leads by marketing lead source, campaign name, or campaign
medium"
type: string
sql: |
case
when ${lightdash.parameters.leads.utm_toggle} = 'lead_source' then ${lead_source}
when ${lightdash.parameters.leads.utm_toggle} = 'utm_medium' then ${utm_medium}
when ${lightdash.parameters.leads.utm_toggle} = 'campaign_name' then ${campaign_name}
end
selected_dim:
selected_dim:
label: Selected dimension
type: string
description: The dimension that is currently selected in the utm_toggle parameter
description: The dimension that is currently selected in the utm_toggle
parameter
sql: ${lightdash.parameters.leads.utm_toggle}}
- name: campaign_name
description: "Name of the marketing campaign associated with the lead (if available)"
description: "Name of the marketing campaign associated with the lead (if
available)"
meta:
dimension:
type: string
Expand All @@ -206,6 +211,12 @@ models:
dimension:
type: string
label: Campaign medium
metrics:
utm_medium_count_distinct_of_campaign_medium:
label: Count distinct of Campaign medium
description: "Count distinct of Campaign medium on the table Leads "
type: count_distinct
filters: []
- name: lead_cost
description: "Cost attributed to acquiring this lead"
meta:
Expand All @@ -217,7 +228,7 @@ models:
type: sum
description: "The sum of lead_cost for selected leads"
format: '$#,##0'
groups: ['Lead Costs']
groups: [ 'Lead Costs' ]
ai_hint: |
Sum of attributed lead acquisition costs. Useful for calculating CAC and evaluating marketing ROI when joined to `deals.total_amount`.
spotlight:
Expand All @@ -229,14 +240,15 @@ models:
type: average
description: "The average lead cost for selected leads"
format: '$#,##0.00'
groups: ['Lead Costs']
groups: [ 'Lead Costs' ]
spotlight:
visibility: show
categories:
- leads
- marketing
- name: lead_status
description: "Current status of the lead (e.g., Open, Contacted, Converted, Disqualified)"
description: "Current status of the lead (e.g., Open, Contacted, Converted,
Disqualified)"
meta:
dimension:
type: string
Expand All @@ -247,10 +259,21 @@ models:
type: timestamp
time_intervals:
[
'DAY', 'WEEK', 'MONTH', 'YEAR', 'QUARTER',
'DAY_OF_MONTH_NUM', 'DAY_OF_YEAR_NUM', 'WEEK_NUM', 'MONTH_NUM',
'QUARTER_NUM', 'YEAR_NUM', 'HOUR_OF_DAY_NUM',
'DAY_OF_WEEK_NAME', 'MONTH_NAME', 'QUARTER_NAME'
'DAY',
'WEEK',
'MONTH',
'YEAR',
'QUARTER',
'DAY_OF_MONTH_NUM',
'DAY_OF_YEAR_NUM',
'WEEK_NUM',
'MONTH_NUM',
'QUARTER_NUM',
'YEAR_NUM',
'HOUR_OF_DAY_NUM',
'DAY_OF_WEEK_NAME',
'MONTH_NAME',
'QUARTER_NAME'
]
- name: converted_at
description: "The timestamp at which the lead was converted"
Expand All @@ -259,14 +282,25 @@ models:
type: timestamp
time_intervals:
[
'DAY', 'WEEK', 'MONTH', 'YEAR', 'QUARTER',
'DAY_OF_MONTH_NUM', 'DAY_OF_YEAR_NUM', 'WEEK_NUM', 'MONTH_NUM',
'QUARTER_NUM', 'YEAR_NUM', 'HOUR_OF_DAY_NUM',
'DAY_OF_WEEK_NAME', 'MONTH_NAME', 'QUARTER_NAME'
'DAY',
'WEEK',
'MONTH',
'YEAR',
'QUARTER',
'DAY_OF_MONTH_NUM',
'DAY_OF_YEAR_NUM',
'WEEK_NUM',
'MONTH_NUM',
'QUARTER_NUM',
'YEAR_NUM',
'HOUR_OF_DAY_NUM',
'DAY_OF_WEEK_NAME',
'MONTH_NAME',
'QUARTER_NAME'
]
- name: sdr_team
description: "The team the SDR belongs to"
meta:
dimension:
type: string
label: "SDR Team"
label: "SDR Team"
Loading