Skip to content
Tutorials Center
My learning

Topics

Lesson 35 of 36 ยท Projects and Practice

Project: Lead Scoring and Pipeline Tracker

Build a small CRM engine in Python: lead capture, deduplication, rule-based scoring, stage transitions, follow-up tasks and a pipeline forecast, all runnable in your browser.

In this project you build the heart of a CRM in Python: capture leads, avoid duplicates, score them by fit and engagement, move them through pipeline stages with rules, create follow-up tasks and produce a forecast. It is a stand-in that teaches the concepts behind real CRM features such as lead assignment, scoring, stage gates and pipeline reports; it is not any vendor's product.

The workflow combines ideas from earlier lessons: duplicates (master data management), weighted pipeline (forecasting and analytics) and KPIs (KPIs, dashboards and business reports).

The model

Objects

Lead A possible customer with a source.
Account The organization behind the lead.
Opportunity A potential deal with a value and stage.
Task A follow-up with an owner and date.

Leads qualify into accounts and opportunities.

1 / 2

Step 1: Capture with duplicate detection

A CRM must not fill with duplicates. Normalize the email and the company name, and compare to existing leads before creating a new record.

Python Step 1: capture and deduplicate

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 2: Rule-based lead scoring

Scoring combines fit (does this look like our ideal customer?) and engagement (is the person interested right now?). Marketing and sales agree on the rules and review them against real win data.

Python Step 2: score leads

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Hot leads go to a salesperson immediately, warm leads get a short sequence, and the rest stay in marketing nurture. Notice the decay: an old, inactive lead loses points.

Step 3: Stage transitions with rules

Pipeline stages should not be moved at will. Define allowed transitions and exit criteria: required fields before a lead can become a proposal, for example a budget and a decision maker.

Python Step 3: a stage machine

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 4: Follow-up tasks and the pipeline forecast

Every open opportunity needs a next step with a date. The forecast uses stage probabilities and flags stale deals.

Python Step 4: tasks, staleness and forecast

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The data hygiene rules (no past close dates, activity within 21 days) keep forecasts honest, which links directly to data quality monitoring.

Extensions to try

  1. Lead assignment: round-robin or by territory and workload.
  2. Response-time SLA: flag hot leads not contacted within one hour.
  3. Conversion analytics: compute conversion per source and use it to update the source points.
  4. Win/loss reasons: require a reason when closing as lost and report the top three.
  5. Duplicates by fuzzy match: reuse the matching from the master data lesson.
  6. Consent: store opt-in status and block outreach without it.
  7. Integration: send won deals to the order-to-cash simulator (order-to-cash project).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the difference between lead fit and engagement?

    Scoring models usually combine a stable profile match with behavioural signals that change over time.
  2. 2. Why add score decay for inactive leads?

    Recent behaviour predicts buying interest better than activity from months ago.
  3. 3. What are exit criteria on a pipeline stage?

    Rules such as budget confirmed and decision maker identified keep stages meaningful and forecasts reliable.
  4. 4. Why halve the value of stale deals in the forecast?

    A deal with no activity for weeks is at higher risk, so a cautious forecast discounts it.

Summary

  • A CRM engine captures leads, prevents duplicates and links leads to accounts and opportunities.
  • Scores combine fit and engagement, with decay; grades drive routing.
  • Stage machines with exit criteria keep the pipeline honest.
  • Tasks and stale-deal rules keep activity current; forecasts weight value by probability.
  • Extend the model with assignment, SLAs, consent and integration.

Next: Practice Exercises and Glossary