fix(analytics): Corregir queries y unificar UI de recomendaciones
Fixes: - CTR 0%: Cambiar query de IS NULL a HAVING clicks=0 para CTR global real - Decay content: Aumentar umbral de 3 a 5 clicks para evitar ruido - Click distribution: Expandir de posiciones 1-5 a 1-10 individual - Remover URL redundante de tabla Top Posts UI: - Convertir 3 secciones de recomendaciones a formato tabla consistente: * ACCIÓN URGENTE: Contenido a Crear * REVISAR: Títulos con CTR 0% * QUICK WINS: Oportunidades Fáciles 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -309,89 +309,124 @@ final class ROI_APU_Analytics_Dashboard
|
||||
|
||||
<!-- 🔴 ACCIÓN URGENTE: Contenido a Crear -->
|
||||
<?php if (!empty($zero_results)) : ?>
|
||||
<div class="recommendation-card mb-4" role="alert"
|
||||
style="border-left: 4px solid #ef4444; background-color: #fef2f2; border-radius: 0.5rem; padding: 1rem;">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h6 class="mb-0 d-flex align-items-center gap-2" style="color: #7f1d1d;">
|
||||
<div class="card mb-4 shadow-sm" style="border-left: 4px solid #ef4444;">
|
||||
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #ef4444; color: white;">
|
||||
<h6 class="mb-0 d-flex align-items-center gap-2">
|
||||
<i class="bi bi-exclamation-triangle-fill"></i>
|
||||
<?php esc_html_e('ACCIÓN URGENTE: Contenido a Crear', 'roi-apu-search'); ?>
|
||||
</h6>
|
||||
<span class="badge" style="background-color: #ef4444;"><?php echo count($zero_results); ?></span>
|
||||
<span class="badge bg-light text-dark"><?php echo count($zero_results); ?></span>
|
||||
</div>
|
||||
<p class="small mb-2" style="color: #991b1b;">
|
||||
<?php esc_html_e('Los usuarios buscan esto pero NO encuentran nada. ¡Crea este contenido!', 'roi-apu-search'); ?>
|
||||
</p>
|
||||
<div class="small">
|
||||
<?php foreach ($zero_results as $index => $term) : ?>
|
||||
<div class="d-flex justify-content-between py-1 <?php echo $index < count($zero_results) - 1 ? 'border-bottom' : ''; ?>" style="border-color: #fecaca !important;">
|
||||
<span style="color: #7f1d1d;">
|
||||
<strong><?php echo esc_html($term['q_term']); ?></strong>
|
||||
</span>
|
||||
<span style="color: #991b1b;">
|
||||
<?php echo esc_html(number_format((int)$term['frecuencia'])); ?> <?php esc_html_e('veces buscado', 'roi-apu-search'); ?>
|
||||
</span>
|
||||
<div class="card-body p-0">
|
||||
<p class="small text-muted px-3 pt-3 mb-2">
|
||||
<?php esc_html_e('Los usuarios buscan esto pero NO encuentran nada. ¡Crea este contenido!', 'roi-apu-search'); ?>
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 70%;"><?php esc_html_e('Término buscado', 'roi-apu-search'); ?></th>
|
||||
<th class="text-center"><?php esc_html_e('Frecuencia', 'roi-apu-search'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($zero_results as $term) : ?>
|
||||
<tr>
|
||||
<td><strong><?php echo esc_html(mb_strimwidth($term['q_term'], 0, 80, '...')); ?></strong></td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-danger"><?php echo esc_html(number_format((int)$term['frecuencia'])); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- 🟡 REVISAR: Títulos con CTR 0% -->
|
||||
<?php if (!empty($ctr_zero)) : ?>
|
||||
<div class="recommendation-card mb-4" role="alert"
|
||||
style="border-left: 4px solid #f59e0b; background-color: #fffbeb; border-radius: 0.5rem; padding: 1rem;">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h6 class="mb-0 d-flex align-items-center gap-2" style="color: #78350f;">
|
||||
<div class="card mb-4 shadow-sm" style="border-left: 4px solid #f59e0b;">
|
||||
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #f59e0b; color: white;">
|
||||
<h6 class="mb-0 d-flex align-items-center gap-2">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
<?php esc_html_e('REVISAR: Títulos con CTR 0%', 'roi-apu-search'); ?>
|
||||
</h6>
|
||||
<span class="badge" style="background-color: #f59e0b;"><?php echo count($ctr_zero); ?></span>
|
||||
<span class="badge bg-light text-dark"><?php echo count($ctr_zero); ?></span>
|
||||
</div>
|
||||
<p class="small mb-2" style="color: #92400e;">
|
||||
<?php esc_html_e('Estos términos tienen resultados pero nadie hace click. Mejora títulos y descripciones.', 'roi-apu-search'); ?>
|
||||
</p>
|
||||
<div class="small">
|
||||
<?php foreach ($ctr_zero as $index => $term) : ?>
|
||||
<div class="d-flex justify-content-between py-1 <?php echo $index < count($ctr_zero) - 1 ? 'border-bottom' : ''; ?>" style="border-color: #fde68a !important;">
|
||||
<span style="color: #78350f;">
|
||||
<strong><?php echo esc_html($term['q_term']); ?></strong>
|
||||
<small>(<?php echo esc_html(number_format((int)$term['resultados'])); ?> <?php esc_html_e('resultados', 'roi-apu-search'); ?>)</small>
|
||||
</span>
|
||||
<span style="color: #92400e;">
|
||||
<?php echo esc_html(number_format((int)$term['busquedas'])); ?> <?php esc_html_e('búsquedas', 'roi-apu-search'); ?> → 0 clicks
|
||||
</span>
|
||||
<div class="card-body p-0">
|
||||
<p class="small text-muted px-3 pt-3 mb-2">
|
||||
<?php esc_html_e('Estos términos tienen resultados pero nadie hace click. Mejora títulos y descripciones.', 'roi-apu-search'); ?>
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 50%;"><?php esc_html_e('Término buscado', 'roi-apu-search'); ?></th>
|
||||
<th class="text-center"><?php esc_html_e('Resultados', 'roi-apu-search'); ?></th>
|
||||
<th class="text-center"><?php esc_html_e('Búsquedas', 'roi-apu-search'); ?></th>
|
||||
<th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($ctr_zero as $term) : ?>
|
||||
<tr>
|
||||
<td><strong><?php echo esc_html(mb_strimwidth($term['q_term'], 0, 60, '...')); ?></strong></td>
|
||||
<td class="text-center"><?php echo esc_html(number_format((int)$term['resultados'])); ?></td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-warning text-dark"><?php echo esc_html(number_format((int)$term['busquedas'])); ?></span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-danger">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- 🎯 QUICK WINS: Oportunidades Fáciles -->
|
||||
<?php if (!empty($quick_wins)) : ?>
|
||||
<div class="recommendation-card mb-4" role="alert"
|
||||
style="border-left: 4px solid #0284c7; background-color: #e7f3ff; border-radius: 0.5rem; padding: 1rem;">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h6 class="mb-0 d-flex align-items-center gap-2" style="color: #0c4a6e;">
|
||||
<div class="card mb-4 shadow-sm" style="border-left: 4px solid #0284c7;">
|
||||
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #0284c7; color: white;">
|
||||
<h6 class="mb-0 d-flex align-items-center gap-2">
|
||||
<i class="bi bi-bullseye"></i>
|
||||
<?php esc_html_e('QUICK WINS: Oportunidades Fáciles', 'roi-apu-search'); ?>
|
||||
</h6>
|
||||
<span class="badge" style="background-color: #0284c7;"><?php echo count($quick_wins); ?></span>
|
||||
<span class="badge bg-light text-dark"><?php echo count($quick_wins); ?></span>
|
||||
</div>
|
||||
<p class="small mb-2" style="color: #075985;">
|
||||
<?php esc_html_e('Términos con clicks que no están en top 1. Una pequeña mejora = más visibilidad.', 'roi-apu-search'); ?>
|
||||
</p>
|
||||
<div class="small">
|
||||
<?php foreach ($quick_wins as $index => $term) : ?>
|
||||
<div class="d-flex justify-content-between py-1 <?php echo $index < count($quick_wins) - 1 ? 'border-bottom' : ''; ?>" style="border-color: #bae6fd !important;">
|
||||
<span style="color: #0c4a6e;">
|
||||
<strong><?php echo esc_html($term['q_term']); ?></strong>
|
||||
</span>
|
||||
<span style="color: #075985;">
|
||||
<?php esc_html_e('Pos.', 'roi-apu-search'); ?> <?php echo esc_html($term['pos_prom']); ?>,
|
||||
CTR <?php echo esc_html($term['ctr']); ?>%
|
||||
</span>
|
||||
<div class="card-body p-0">
|
||||
<p class="small text-muted px-3 pt-3 mb-2">
|
||||
<?php esc_html_e('Términos con clicks que no están en top 1. Una pequeña mejora = más visibilidad.', 'roi-apu-search'); ?>
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 50%;"><?php esc_html_e('Término buscado', 'roi-apu-search'); ?></th>
|
||||
<th class="text-center"><?php esc_html_e('Pos. Prom.', 'roi-apu-search'); ?></th>
|
||||
<th class="text-center"><?php esc_html_e('CTR', 'roi-apu-search'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($quick_wins as $term) : ?>
|
||||
<tr>
|
||||
<td><strong><?php echo esc_html(mb_strimwidth($term['q_term'], 0, 60, '...')); ?></strong></td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-secondary"><?php echo esc_html($term['pos_prom']); ?></span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-info text-dark"><?php echo esc_html($term['ctr']); ?>%</span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -683,7 +718,6 @@ final class ROI_APU_Analytics_Dashboard
|
||||
<tr>
|
||||
<td>
|
||||
<strong><?php echo esc_html(mb_strimwidth($post['post_title'], 0, 80, '...')); ?></strong>
|
||||
<br><small class="text-muted">/<?php echo esc_html($post['post_name']); ?>/</small>
|
||||
</td>
|
||||
<td class="text-center"><?php echo esc_html(number_format((int)$post['clicks'])); ?></td>
|
||||
<td class="text-center">
|
||||
|
||||
Reference in New Issue
Block a user