Tech With Galvan
Back to Articles
AutomationMar 15, 2029 • 4 min read

How to Automatically Score and Sort Leads

Automatically score and sort leads — a simple lead scoring system with Python and Google Sheets. Prioritize your best leads.

Galvan
Galvan

Founder & Creator

Introduction

Not all leads are equal. Some are ready to buy; others are just browsing. Lead scoring assigns a numeric value to each lead based on their likelihood to convert, so you can prioritize your time on the best prospects.

This post builds a simple lead scoring system with Python and Google Sheets.

What is lead scoring?

Lead scoring assigns points based on:

  • Demographic fit (job title, company size, industry)
  • Behavioral signals (website visits, email opens, form submissions)
  • Intent signals (requested a quote, asked about pricing, mentioned budget)

Higher score = more likely to convert = contact first.

The scoring model

Point system

Signal Points Why
Has email +10 Basic contact info
Has phone +10 Can call directly
Has company name +10 B2B lead
Mentioned budget +20 Ready to spend
Mentioned timeline +15 Urgent need
Requested quote +25 High intent
Visited pricing page +15 Comparing options
Opened 3+ emails +10 Engaged
Downloaded resource +10 Interested
Referred by existing client +30 Warm lead
No-show on call -20 Low commitment
Unsubscribed -50 Not interested

Score ranges

Score Category Action
80+ Hot Call immediately
50-79 Warm Email + follow up within 24h
20-49 Cool Nurture with content
<20 Cold Low priority, check back in 30 days

Step 1: Add scoring to your CRM

Add a “Score” column to your Google Sheets CRM (see Simple CRM).

Manual scoring

When a new lead comes in, score them manually based on the signals above.

Automated scoring (Apps Script)

function scoreLeads() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Leads");
  const data = sheet.getDataRange().getValues();
  
  for (let i = 1; i < data.length; i++) {
    const row = data[i];
    const name = row[0];
    const email = row[1];
    const phone = row[2];
    const company = row[3];
    const source = row[4];
    const message = row[8];  // Message column
    
    let score = 0;
    
    // Contact info
    if (email) score += 10;
    if (phone) score += 10;
    if (company) score += 10;
    
    // Source
    if (source === "Referral") score += 30;
    if (source === "LinkedIn") score += 20;
    if (source === "Website") score += 15;
    if (source === "Cold Email") score += 10;
    
    // Message quality
    if (message && message.length > 50) score += 20;
    if (message && message.toLowerCase().includes("budget")) score += 15;
    if (message && message.toLowerCase().includes("urgent")) score += 10;
    if (message && message.toLowerCase().includes("quote")) score += 25;
    
    sheet.getRange(i + 1, 7).setValue(score);  // Score column
  }
}

Set up a daily trigger or run on new lead entry.

Step 2: Python-based scoring

For more complex scoring with multiple data sources:

import pandas as pd

def score_lead(lead):
    score = 0
    
    # Contact completeness
    if lead.get("email"): score += 10
    if lead.get("phone"): score += 10
    if lead.get("company"): score += 10
    
    # Source
    source_scores = {"referral": 30, "linkedin": 20, "website": 15, "cold_email": 10}
    score += source_scores.get(lead.get("source", "").lower(), 0)
    
    # Message analysis
    msg = lead.get("message", "").lower()
    if len(msg) > 50: score += 20
    if "budget" in msg: score += 15
    if "urgent" in msg: score += 10
    if "quote" in msg or "price" in msg: score += 25
    if "asap" in msg or "immediately" in msg: score += 10
    
    # Engagement
    score += lead.get("email_opens", 0) * 2
    score += lead.get("page_visits", 0) * 3
    
    # Negative signals
    if lead.get("no_show"): score -= 20
    if lead.get("unsubscribed"): score -= 50
    
    return max(0, min(100, score))  # clamp to 0-100

# Apply to all leads
df = pd.read_csv("leads.csv")
df["score"] = df.apply(score_lead, axis=1)
df["category"] = df["score"].apply(lambda s: "Hot" if s >= 80 else "Warm" if s >= 50 else "Cool" if s >= 20 else "Cold")
df = df.sort_values("score", ascending=False)
df.to_csv("leads_scored.csv", index=False)

Step 3: Sort and prioritize

In Google Sheets

  1. Click on the Score column header
  2. Data → Sort range → Sort by Score (Z to A)
  3. Hot leads appear at the top

In Python

df = df.sort_values("score", ascending=False)
# Hot leads first

Auto-sort with Apps Script

function sortLeads() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Leads");
  const range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());
  range.sort({ column: 7, ascending: false });  // Sort by Score column (7)
}

Set up a trigger to run after scoring.

Step 4: Automate actions based on score

Hot leads (80+)

  • Send instant WhatsApp alert
  • Assign to top salesperson
  • Call within 5 minutes

Warm leads (50-79)

  • Send follow-up email within 24 hours
  • Assign to salesperson
  • Schedule a discovery call

Cool leads (20-49)

  • Add to nurture sequence
  • Send educational content
  • Check back in 2 weeks

Cold leads (<20)

  • Add to long-term nurture
  • Send monthly newsletter
  • Check back in 30 days

Automated routing

def route_lead(lead):
    score = lead["score"]
    if score >= 80:
        send_whatsapp_alert(lead)  # instant alert
        assign_to_salesperson(lead, "top")
    elif score >= 50:
        send_followup_email(lead)  # within 24h
        assign_to_salesperson(lead, "standard")
    elif score >= 20:
        add_to_nurture_sequence(lead)  # educational content
    else:
        add_to_long_term_nurture(lead)  # monthly check-in

Common mistakes

  • Overcomplicating the model — start with 5-6 signals, not 20
  • Not validating the model — check if high-scored leads actually convert
  • Static scoring — scores should update as leads engage (email opens, page visits)
  • Ignoring negative signals — a lead who unsubscribed should lose points
  • Not acting on scores — scoring is useless if you don’t prioritize based on it

Key Concepts

  • Lead scoring = assigning numeric value to lead quality
  • Demographic fit = how well the lead matches your ideal customer
  • Behavioral signals = actions the lead takes (email opens, page visits)
  • Intent signals = signs the lead is ready to buy
  • Routing = directing leads to the right person/action based on score

What to Try Next

FAQ

How do I know if my scoring model is good?

Track conversion rates by score range. If hot leads (80+) convert at 30%+ and cold leads (<20) convert at <5%, your model works. Adjust weights based on actual conversion data.

Should I use AI for lead scoring?

For simple B2B sales, rule-based scoring (this post) is enough. For complex sales with many signals, use ML (scikit-learn, XGBoost). Start simple; add ML when you have 1000+ leads with outcome data.

How often should scores update?

Real-time for behavioral signals (email opens, page visits). Daily for demographic/intent signals. The score should reflect the lead’s current state, not their state when they first contacted you. See Simple CRM in Google Sheets.