File size: 14,889 Bytes
dd9e1be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29d043a
 
 
dd9e1be
29d043a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6100ddf
29d043a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd9e1be
6100ddf
 
 
 
8624192
 
 
dd9e1be
8624192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd9e1be
8624192
6100ddf
 
 
 
8624192
 
 
dd9e1be
8624192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd9e1be
8624192
dd9e1be
 
8624192
 
dd9e1be
8624192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd9e1be
8624192
dd9e1be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
document.addEventListener('DOMContentLoaded', function() {
    const data = [
        { location: 'Chadwell', metric: 'Avg CPC', baseline: '3.47', current: '1.80', trend: 'Improved' },
        { location: 'Chadwell', metric: 'Cost per Conversion', baseline: '3.42', current: 'Lower or Stable', trend: 'Improved' },
        { location: 'Ellicott City ER', metric: 'Avg CPC', baseline: '1.77', current: '1.80', trend: 'Stable' },
        { location: 'Ellicott City ER', metric: 'Cost per Conversion', baseline: '5.81', current: 'Lower', trend: 'Improved' },
        { location: 'Bay Beach', metric: 'Avg CPC', baseline: '3.19', current: '2.79', trend: 'Improved' },
        { location: 'Bay Beach', metric: 'Cost per Conversion', baseline: '7.42', current: 'Lower', trend: 'Improved' },
        { location: 'Beltsville', metric: 'Avg CPC', baseline: '1.96', current: '2.00', trend: 'Stable' },
        { location: "Dr Dan's", metric: 'Avg CPC', baseline: '19.92', current: 'Much Lower', trend: 'Improved' },
        { location: 'Hoffman', metric: 'Avg CPC', baseline: '3.60', current: '3.50', trend: 'Stable' },
        { location: 'Mixed Pet', metric: 'Avg CPC', baseline: '10.43', current: 'Lower', trend: 'Improved' },
        { location: 'Colonial', metric: 'Avg CPC', baseline: '9.15', current: 'Slightly Lower', trend: 'Improved' },
        { location: 'Jackson Square', metric: 'Avg CPC', baseline: '6.21', current: 'Lower', trend: 'Improved' }
    ];
    // Create two tables - one for CPC and one for Conversion metrics
    const cpcData = data.filter(item => item.metric === 'Avg CPC');
    const conversionData = data.filter(item => item.metric === 'Cost per Conversion');

    // Create CPC table
    const cpcTable = document.createElement('div');
    cpcTable.className = 'mt-8 bg-white rounded-xl shadow-md overflow-hidden';
    cpcTable.innerHTML = `
        <div class="px-6 py-4 border-b border-gray-200">
            <h2 class="text-xl font-semibold text-gray-800">CPC Performance</h2>
        </div>
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-200">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Location</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">October Baseline</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Current (Nov-Dec)</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Trend</th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200" id="cpc-table">
                    ${cpcData.map(item => `
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${item.location}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.baseline}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.current}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm ${item.trend === 'Improved' ? 'trend-improved' : item.trend === 'Stable' ? 'trend-stable' : 'trend-worsened'} font-semibold">
                                <i data-feather="${item.trend === 'Improved' ? 'trending-up' : item.trend === 'Stable' ? 'minus' : 'trending-down'}" class="inline mr-1"></i>
                                ${item.trend}
                            </td>
                        </tr>
                    `).join('')}
                </tbody>
            </table>
        </div>
    `;

    // Create Conversion table
    const conversionTable = document.createElement('div');
    conversionTable.className = 'mt-8 bg-white rounded-xl shadow-md overflow-hidden';
    conversionTable.innerHTML = `
        <div class="px-6 py-4 border-b border-gray-200">
            <h2 class="text-xl font-semibold text-gray-800">Conversion Performance</h2>
        </div>
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-200">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Location</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">October Baseline</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Current (Nov-Dec)</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Trend</th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200" id="conversion-table">
                    ${conversionData.map(item => `
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${item.location}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.baseline}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.current}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm ${item.trend === 'Improved' ? 'trend-improved' : item.trend === 'Stable' ? 'trend-stable' : 'trend-worsened'} font-semibold">
                                <i data-feather="${item.trend === 'Improved' ? 'trending-up' : item.trend === 'Stable' ? 'minus' : 'trending-down'}" class="inline mr-1"></i>
                                ${item.trend}
                            </td>
                        </tr>
                    `).join('')}
                </tbody>
            </table>
        </div>
    `;

    // Remove the original table container
    const originalTable = document.querySelector('.mt-12.bg-white.rounded-xl.shadow-md.overflow-hidden');
    if (originalTable) {
        originalTable.remove();
    }

    // Insert the new tables
    const main = document.querySelector('main');
    main.insertBefore(cpcTable, document.querySelector('.mt-12'));
    main.insertBefore(conversionTable, document.querySelector('.mt-12'));
// Create summary cards
    const cardsContainer = document.querySelector('.grid');
    
    // Avg CPC Summary
    const avgCPCData = data.filter(item => item.metric === 'Avg CPC');
    const improvedCPC = avgCPCData.filter(item => item.trend === 'Improved').length;
    
    const cpcCard = document.createElement('div');
    cpcCard.className = 'bg-white rounded-xl shadow-card p-6';
    cpcCard.innerHTML = `
        <div class="flex justify-between items-start">
            <div>
                <p class="text-sm font-medium text-gray-500">Avg CPC</p>
                <h3 class="mt-1 text-2xl font-semibold text-gray-900">${avgCPCData.length} Locations</h3>
            </div>
            <div class="p-3 rounded-lg bg-blue-100 text-blue-600">
                <i data-feather="dollar-sign"></i>
            </div>
        </div>
        <div class="mt-6">
            <div class="flex items-center justify-between mb-2">
                <span class="text-sm font-medium text-gray-500">Improved</span>
                <span class="text-sm font-semibold text-green-600">${improvedCPC} (${Math.round((improvedCPC/avgCPCData.length)*100)}%)</span>
            </div>
            <div class="w-full bg-gray-200 rounded-full h-2">
                <div class="bg-green-500 h-2 rounded-full" style="width: ${(improvedCPC/avgCPCData.length)*100}%"></div>
            </div>
        </div>
    `;
    cardsContainer.appendChild(cpcCard);

    // Cost per Conversion Summary
    const convData = data.filter(item => item.metric === 'Cost per Conversion');
    const improvedConv = convData.filter(item => item.trend === 'Improved').length;
    
    const convCard = document.createElement('div');
    convCard.className = 'bg-white rounded-xl shadow-card p-6';
    convCard.innerHTML = `
        <div class="flex justify-between items-start">
            <div>
                <p class="text-sm font-medium text-gray-500">Cost per Conversion</p>
                <h3 class="mt-1 text-2xl font-semibold text-gray-900">${convData.length} Locations</h3>
            </div>
            <div class="p-3 rounded-lg bg-purple-100 text-purple-600">
                <i data-feather="activity"></i>
            </div>
        </div>
        <div class="mt-6">
            <div class="flex items-center justify-between mb-2">
                <span class="text-sm font-medium text-gray-500">Improved</span>
                <span class="text-sm font-semibold text-green-600">${improvedConv} (${Math.round((improvedConv/convData.length)*100)}%)</span>
            </div>
            <div class="w-full bg-gray-200 rounded-full h-2">
                <div class="bg-green-500 h-2 rounded-full" style="width: ${(improvedConv/convData.length)*100}%"></div>
            </div>
        </div>
    `;
    cardsContainer.appendChild(convCard);

    // Overall Performance
    const overallCard = document.createElement('div');
    overallCard.className = 'bg-white rounded-xl shadow-card p-6';
    overallCard.innerHTML = `
        <div class="flex justify-between items-start">
            <div>
                <p class="text-sm font-medium text-gray-500">Overall Performance</p>
                <h3 class="mt-1 text-2xl font-semibold text-gray-900">${data.length} Metrics</h3>
            </div>
            <div class="p-3 rounded-lg bg-green-100 text-green-600">
                <i data-feather="bar-chart-2"></i>
            </div>
        </div>
        <div class="mt-6 space-y-4">
            <div>
                <div class="flex items-center justify-between mb-1">
                    <span class="text-sm font-medium text-gray-500">Improved</span>
                    <span class="text-sm font-semibold text-green-600">${data.filter(item => item.trend === 'Improved').length}</span>
                </div>
                <div class="w-full bg-gray-200 rounded-full h-2">
                    <div class="bg-green-500 h-2 rounded-full" style="width: ${(data.filter(item => item.trend === 'Improved').length/data.length)*100}%"></div>
                </div>
            </div>
            <div>
                <div class="flex items-center justify-between mb-1">
                    <span class="text-sm font-medium text-gray-500">Stable</span>
                    <span class="text-sm font-semibold text-yellow-500">${data.filter(item => item.trend === 'Stable').length}</span>
                </div>
                <div class="w-full bg-gray-200 rounded-full h-2">
                    <div class="bg-yellow-400 h-2 rounded-full" style="width: ${(data.filter(item => item.trend === 'Stable').length/data.length)*100}%"></div>
                </div>
            </div>
        </div>
    `;
    cardsContainer.appendChild(overallCard);
    // Add strategic insights section
    const insightsData = [
        { location: 'Chadwell', improved: 'CPC down ~48 percent, higher engagement', constrained: 'Call tracking not enabled', next: 'Enable call tracking and scale service campaigns' },
        { location: 'Ellicott City ER', improved: 'Efficiency improved, calls rebounded', constrained: 'Temporary pharmacy policy pause', next: 'Restore budget and add call-only emergency ads' },
        { location: 'Bay Beach', improved: 'Higher call and direction volume, CPC down', constrained: 'Impression share capped', next: 'Scale budget and launch remarketing' },
        { location: 'Beltsville', improved: 'Improved traffic quality', constrained: 'Funnel optimization needed', next: 'Landing page and tracking improvements' },
        { location: "Dr Dan's", improved: 'CPC significantly reduced', constrained: 'Tracking limitations', next: 'Fix tracking and relaunch campaigns' },
        { location: 'Hoffman', improved: 'Higher engagement time', constrained: 'Low booking actions', next: 'Shift budget to booking-intent ads' },
        { location: 'Mixed Pet', improved: 'Lower CPC and deeper sessions', constrained: 'Weak calls to action', next: 'Deploy booking-first landing pages' },
        { location: 'Colonial', improved: 'Stable performance', constrained: 'UX and engagement issues', next: 'UX audit and simplified booking path' },
        { location: 'Jackson Square', improved: 'Stable engagement', constrained: 'Limited scale and tracking', next: 'Improve tracking and cautiously scale' }
    ];

    const insightsContainer = document.createElement('div');
    insightsContainer.className = 'mt-12 bg-white rounded-xl shadow-md overflow-hidden';
    insightsContainer.innerHTML = `
        <div class="px-6 py-4 border-b border-gray-200">
            <h2 class="text-xl font-semibold text-gray-800">Strategic Insights</h2>
        </div>
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-200">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Location</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">What Improved</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">What Was Constrained</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">What's Next</th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200" id="insights-table">
                    ${insightsData.map(item => `
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${item.location}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.improved}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.constrained}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.next}</td>
                        </tr>
                    `).join('')}
                </tbody>
            </table>
        </div>
    `;
    document.querySelector('main').appendChild(insightsContainer);

    // Refresh feather icons after dynamic content is added
    feather.replace();
});