Lead nurturing implementation on website

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Implementing Lead Nurturing on Website

Lead nurturing is an automated series of communications that "warms up" a lead from first touch to purchase. Includes email sequences, trigger emails, personalized content, and behavior-based remarketing.

System Architecture

Registration/Subscription → Segment Definition → Enroll in Sequence →
→ Timer + Conditions → Send Email → Track Opens and Clicks →
→ Transition to Another Sequence on Target Action

Data Model

Schema::create('nurture_sequences', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->string('trigger');            // 'trial_started', 'whitepaper_downloaded', 'pricing_page_3x'
    $table->json('conditions')->nullable(); // {"plan": "free", "source": "organic"}
    $table->boolean('is_active')->default(true);
    $table->timestamps();
});

Schema::create('nurture_emails', function (Blueprint $table) {
    $table->id();
    $table->foreignId('sequence_id')->constrained('nurture_sequences')->cascadeOnDelete();
    $table->integer('delay_hours');       // Send N hours after previous
    $table->string('subject');
    $table->string('template');           // Blade template name
    $table->json('conditions')->nullable(); // Additional send conditions
    $table->integer('order')->default(0);
});

Schema::create('nurture_enrollments', function (Blueprint $table) {
    $table->id();
    $table->foreignId('sequence_id')->constrained('nurture_sequences');
    $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
    $table->string('email');
    $table->integer('current_step')->default(0);
    $table->enum('status', ['active', 'completed', 'exited', 'converted'])->default('active');
    $table->timestamp('next_email_at')->nullable();
    $table->timestamp('converted_at')->nullable();
    $table->timestamps();
});

Sequence Management Service

class NurtureService
{
    public function enroll(string $email, string $trigger, array $context = [], ?int $userId = null): void
    {
        // Find matching sequences for trigger
        $sequences = NurtureSequence::active()
            ->where('trigger', $trigger)
            ->get()
            ->filter(fn($seq) => $this->matchesConditions($seq->conditions, $context));

        foreach ($sequences as $sequence) {
            // Don't enroll if already in active sequence
            $existing = NurtureEnrollment::where('sequence_id', $sequence->id)
                ->where('email', $email)
                ->whereIn('status', ['active'])
                ->exists();

            if ($existing) continue;

            $firstEmail = $sequence->emails()->orderBy('order')->first();

            NurtureEnrollment::create([
                'sequence_id'   => $sequence->id,
                'user_id'       => $userId,
                'email'         => $email,
                'current_step'  => 0,
                'next_email_at' => now()->addHours($firstEmail->delay_hours ?? 0),
            ]);
        }
    }

    public function exit(string $email, string $reason = 'manual'): void
    {
        NurtureEnrollment::where('email', $email)
            ->where('status', 'active')
            ->update(['status' => 'exited']);
    }

    public function markConverted(string $email): void
    {
        NurtureEnrollment::where('email', $email)
            ->where('status', 'active')
            ->update(['status' => 'converted', 'converted_at' => now()]);
    }

    private function matchesConditions(?array $conditions, array $context): bool
    {
        if (!$conditions) return true;
        foreach ($conditions as $key => $value) {
            if (($context[$key] ?? null) != $value) return false;
        }
        return true;
    }
}

Job for Scheduled Email Sending

// Runs every 15 minutes via Scheduler
class ProcessNurtureEmails implements ShouldQueue
{
    public function handle(): void
    {
        $enrollments = NurtureEnrollment::where('status', 'active')
            ->where('next_email_at', '<=', now())
            ->with(['sequence.emails'])
            ->get();

        foreach ($enrollments as $enrollment) {
            $emails = $enrollment->sequence->emails->sortBy('order');
            $currentEmail = $emails->get($enrollment->current_step);

            if (!$currentEmail) {
                $enrollment->update(['status' => 'completed']);
                continue;
            }

            // Check additional conditions
            if ($currentEmail->conditions && !$this->checkStepConditions($enrollment, $currentEmail->conditions)) {
                // Skip step
                $this->advanceToNextStep($enrollment, $emails);
                continue;
            }

            // Check if user unsubscribed
            if (EmailUnsubscribe::where('email', $enrollment->email)->exists()) {
                $enrollment->update(['status' => 'exited']);
                continue;
            }

            // Send email
            Mail::to($enrollment->email)->queue(
                new NurtureEmail($enrollment, $currentEmail)
            );

            $this->advanceToNextStep($enrollment, $emails);
        }
    }

    private function advanceToNextStep(NurtureEnrollment $enrollment, Collection $emails): void
    {
        $nextStep = $enrollment->current_step + 1;
        $nextEmail = $emails->get($nextStep);

        if ($nextEmail) {
            $enrollment->update([
                'current_step'  => $nextStep,
                'next_email_at' => now()->addHours($nextEmail->delay_hours),
            ]);
        } else {
            $enrollment->update(['status' => 'completed', 'current_step' => $nextStep]);
        }
    }
}

Example Trial Sequence

Day 0: "Welcome! Here's how to start" → Onboarding
Day 1: "3 features that save time" → Value
Day 3: "Video: how other companies use us" → Social Proof
Day 5: "Did you use feature X?" → Engagement check (send only if not used)
Day 7: "Your trial ends in 7 days" → Urgency
Day 10: "Special offer just for you" → Offer
Day 14: "What did you like/dislike?" → CSAT + Retention

Exit Triggers

// Purchase Observer
class OrderObserver
{
    public function created(Order $order): void
    {
        // On purchase — exit all nurture sequences
        app(NurtureService::class)->markConverted($order->user->email);
    }
}

// On CRM opportunity creation — notify system
class HandleCrmOpportunityCreated
{
    public function handle(): void
    {
        app(NurtureService::class)->exit($this->email, reason: 'crm_opportunity');
    }
}

Sequence Analytics

-- Conversion by sequences
SELECT
  s.name,
  COUNT(e.id) AS enrolled,
  COUNT(e.id) FILTER (WHERE e.status = 'converted') AS converted,
  ROUND(100.0 * COUNT(e.id) FILTER (WHERE e.status = 'converted') / NULLIF(COUNT(e.id), 0), 1) AS conversion_rate,
  ROUND(AVG(EXTRACT(EPOCH FROM (e.converted_at - e.created_at)) / 3600)) AS avg_hours_to_convert
FROM nurture_sequences s
LEFT JOIN nurture_enrollments e ON e.sequence_id = s.id
GROUP BY s.id, s.name
ORDER BY conversion_rate DESC;

Timeline

A complete lead nurturing system with sequences, conditions, and analytics: 10–14 business days.