@extends('layouts.customer') @section('title', 'Analytics') @section('page-title', 'Email Analytics') @section('content')
@php $rangeLabel = ((int) $range === 30) ? 'Last 30 Days' : 'Last 7 Days'; $deltas = $summary['deltas'] ?? []; $linePoints = collect($rateSeries ?? [])->map(function ($row, $i) { $x = (int) $i; $open = (float) ($row['open_rate'] ?? 0); $ct = (float) ($row['click_through'] ?? 0); $click = (float) ($row['click_rate'] ?? 0); return [ 'x' => $x, 'day' => $row['day'] ?? null, 'open_rate' => $open, 'click_through' => $ct, 'click_rate' => $click, ]; })->values(); $lineMax = max(1, (float) $linePoints->max(fn ($p) => max($p['open_rate'], $p['click_through'], $p['click_rate']))); $toSvgPath = function ($key) use ($linePoints, $lineMax) { if ($linePoints->count() <= 1) { return ''; } $w = 100; $h = 100; $n = max(1, $linePoints->count() - 1); return $linePoints->map(function ($p, $idx) use ($key, $lineMax, $w, $h, $n) { $x = ($idx / $n) * $w; $y = $h - (($p[$key] / $lineMax) * $h); $cmd = $idx === 0 ? 'M' : 'L'; return $cmd . number_format($x, 2, '.', '') . ' ' . number_format($y, 2, '.', ''); })->implode(' '); }; $pathOpen = $toSvgPath('open_rate'); $pathClickThrough = $toSvgPath('click_through'); $pathClick = $toSvgPath('click_rate'); $deviceStats = collect($deviceStats ?? []); $deviceMax = max(1, (int) $deviceStats->max(fn ($r) => max((int) ($r['opened'] ?? 0), (int) ($r['clicked'] ?? 0)))); @endphp
Sent
{{ number_format((int) ($summary['total'] ?? 0)) }}
{{ $rangeLabel }} @php $sentDelta = $deltas['sent'] ?? null; @endphp @if($sentDelta !== null) {{ $sentDelta >= 0 ? '+' : '' }}{{ number_format((float) $sentDelta, 2) }}% @endif
Open Rate
{{ number_format((float) ($summary['open_rate'] ?? 0), 2) }}%
{{ number_format((int) ($summary['opened'] ?? 0)) }} Opened @php $openDelta = (float) ($deltas['open_rate'] ?? 0); @endphp {{ $openDelta >= 0 ? '+' : '' }}{{ number_format($openDelta, 2) }}%
Click Rate
{{ number_format((float) ($summary['click_rate'] ?? 0), 2) }}%
{{ number_format((int) ($summary['clicked'] ?? 0)) }} Clicked @php $clickDelta = (float) ($deltas['click_rate'] ?? 0); @endphp {{ $clickDelta >= 0 ? '+' : '' }}{{ number_format($clickDelta, 2) }}%
Click Through
{{ number_format((float) ($summary['click_through'] ?? 0), 2) }}%
{{ number_format((int) ($summary['clicked'] ?? 0)) }} Click Through @php $ctDelta = (float) ($deltas['click_through'] ?? 0); @endphp {{ $ctDelta >= 0 ? '+' : '' }}{{ number_format($ctDelta, 2) }}%
Delivery
Delivered Rate
{{ number_format((float) ($summary['delivery_rate'] ?? 0), 2) }}%
{{ number_format((int) ($summary['delivered'] ?? 0)) }} Delivered
Hard Bounce Rate
{{ number_format((float) ($summary['hard_bounce_rate'] ?? 0), 2) }}%
{{ number_format((int) ($summary['hard_bounced'] ?? 0)) }} Hard bounced
Unsubscribed Rate
{{ number_format((float) ($summary['unsubscribe_rate'] ?? 0), 2) }}%
{{ number_format((int) ($summary['unsubscribed'] ?? 0)) }} Unsubscribed
Spam Report Rate
{{ number_format((float) ($summary['spam_rate'] ?? 0), 2) }}%
{{ number_format((int) ($summary['complained'] ?? 0)) }} Reported
Email Data Chart
Click through rate
Open rate
Click rate
@foreach(collect($rateSeries ?? [])->take(4) as $i => $row)
{{ \Carbon\Carbon::parse($row['day'])->format('M d') }}
@endforeach
Performance By Device Type
Opened
Clicks
@foreach($deviceStats as $row) @php $openedCount = (int) ($row['opened'] ?? 0); $clickedCount = (int) ($row['clicked'] ?? 0); $openedW = round(($openedCount / $deviceMax) * 100, 2); $clickedW = round(($clickedCount / $deviceMax) * 100, 2); @endphp
{{ $row['label'] }}
{{ $openedCount }} Opened ยท {{ $clickedCount }} Clicks
@endforeach
All Email Performance
Sent Emails
Manage Column Export
@forelse($campaigns as $c) @empty @endforelse
Email Publish Date Sent Click-Through Rate Delivered Rate Unsubscribed Rate Spam Report Rate
{{ $c['name'] }}
@php $publishedAt = $c['published_at'] ?? null; @endphp {{ $publishedAt ? \Carbon\Carbon::parse($publishedAt)->format('n/j/Y') : '-' }} {{ number_format((int) ($c['sent'] ?? 0)) }} {{ number_format((float) ($c['click_through'] ?? 0), 2) }}% {{ number_format((float) ($c['delivered_rate'] ?? 0), 2) }}% {{ number_format((float) ($c['unsubscribe_rate'] ?? 0), 2) }}% {{ number_format((float) ($c['spam_rate'] ?? 0), 2) }}%
No campaigns found in this period.
@if($campaigns->hasPages())
{{ $campaigns->links() }}
@endif
@endsection @push('scripts') @endpush