Create a CTR decay detector: snippet changes, competitor deltas, and refresh cadence.
- User
Create a CTR decay detector: snippet changes, competitor deltas, and refresh cadence.
Assistant
Create a CTR decay detector: snippet changes, competitor deltas, and refresh cadence.
The user wants a "CTR decay detector." This isn't a standard, off-the-shelf software package with a single specific name. It's a concept or a custom tool for SEO and digital marketing analysis. The prompt specifies three key components to track:
Goal: Create a system or framework (likely a Python script or a conceptual architecture) that monitors these factors to explain why Click-Through Rate (CTR) is decaying for a given set of keywords or pages.
Approach: I need to design a solution. Since I cannot deploy a live server, I will provide a Python-based framework/script that acts as this detector. It needs to simulate or integrate with APIs (like Google Search Console and a SERP API).
Core Components of the Solution:
Drafting the Python Script Structure:
CTRDecayDetector:
__init__: Setup API clients.fetch_gsc_data: Get performance over time.fetch_serp_data: Get current layout and competitors.detect_decay: Simple trend analysis (e.g., rolling average vs current).analyze_serp_changes: This is the tricky part without a live DB. I'll mock the "previous state" vs "current state" to show the logic.recommend_refresh_cadence: Heuristic logic (e.g., "CTR dropped 10% in 2 weeks -> Update immediately").Refining the Features:
Code Implementation Details:
pandas for data manipulation.Step-by-Step Plan:
Detector class.Self-Correction/Refinement during thought process:
Final Output Structure:
CTRDecayDetector.Let's write the code with placeholders for APIs but runnable with generated data.
Dependencies: pandas, numpy (standard data science stack).
Code Logic - Snippet Changes: Compare prev_serp_features (e.g., ['standard']) vs curr_serp_features (e.g., ['ai_overview', 'featured_snippet']). If overlap is low or new "zero-click" features appear, flag it.
Code Logic - Competitor Deltas: Compare prev_competitors list vs curr_competitors. If rank 1 or 2 changed, flag "Competitor Displacement."
Code Logic - Refresh: If decay > threshold, calculate days since last update.
Let's assemble. This is a system design and implementation prompt. I will provide a Python framework that acts as a CTR Decay Detector. This script simulates the aggregation of Google Search Console (GSC) data and SERP analysis to diagnose why CTR is dropping.
To detect decay effectively, we must separate External Decay (SERP changes) from Internal Decay (Content staleness).
You will need pandas installed (pip install pandas). I have included a MockDataGenerator class so you can run this immediately without connecting real APIs.
This detector separates correlation from causation. When CTR drops, check the diagnosis list in the output:
New SERP features.Rank dropped or New competitor entered.top_competitors identified in the logic. Update your Title Tags and Meta Descriptions to match or exceed their value proposition.days_since_last_refresh vs Decay Magnitude.decay_pct is high (>15%) AND it's been > 60 days since an update, the content is stale.recommended_frequency. If it says "7 Days", you are in a "Query Deserves Freshness" (QDF) niche (e.g., news, tech specs). You must update constantly. If it says "90 Days", you are in an evergreen niche and the decay is likely due to external factors (Competitors).import pandas as pd
import numpy as np
from datetime import datetime, timedelta
import random
# ==========================================
# 1. MOCK DATA GENERATOR (For Demonstration)
# ==========================================
class MockDataGenerator:
"""Simulates GSC and SERP data for testing."""
@staticmethod
def generate_gsc_data(days=90, decay_start_day=60, severity=0.2):
dates = [datetime.now() - timedelta(days=x) for x in range(days)]
base_ctr = 0.05
data = []
for i, d in enumerate(dates):
# Simulate decay logic
if i > (days - decay_start_day):
# Random walk downwards
current_ctr = base_ctr * (1 - severity * random.random())
else:
# Normal fluctuation
current_ctr = base_ctr * (1 + (random.random() * 0.1 - 0.05))
data.append({
'date': d,
'clicks': int(1000 * current_ctr),
'impressions': 1000,
'ctr': current_ctr
})
return pd.DataFrame(data)
@staticmethod
def generate_serp_history():
"""Simulates snapshots of the SERP for a specific keyword over time."""
return [
{'date': datetime.now() - timedelta(days=90), 'features': ['blue_links'], 'top_competitors': ['Competitor A', 'Me', 'Competitor B']},
{'date': datetime.now() - timedelta(days=30), 'features': ['blue_links'], 'top_competitors': ['Competitor A', 'Me', 'Competitor B']},
# The Change Event
{'date': datetime.now() - timedelta(days=5), 'features': ['featured_snippet', 'ai_overview'], 'top_competitors': ['Competitor A', 'Me', 'Competitor C (New)']},
]
# ==========================================
# 2. CTR DECAY DETECTOR
# ==========================================
class CTRDecayDetector:
def __init__(self, gsc_df, serp_history, url_refresh_log):
self.gsc_df = gsc_df
self.serp_history = serp_history
self.refresh_log = url_refresh_log # Dict: {'last_updated': datetime}
def analyze(self):
# 1. Calculate Decay Metrics
recent = self.gsc_df.head(7)['ctr'].mean()
baseline = self.gsc_df.tail(30).head(30)['ctr'].mean()
decay_pct = (baseline - recent) / baseline
# 2. Diagnose Causes
causes = self._diagnose_causes()
# 3. Calculate Refresh Cadence
refresh_recommendation = self._calculate_cadence(decay_pct)
return {
"status": "DECAY_DETECTED" if decay_pct > 0.15 else "STABLE",
"decay_percentage": f"{decay_pct:.2%}",
"diagnosis": causes,
"action": refresh_recommendation
}
def _diagnose_causes(self):
diagnosis = []
# Check SERP Features (Snippet Changes)
old_serp = self.serp_history[-2] # Previous snapshot
new_serp = self.serp_history[-1] # Latest snapshot
# A. Check for new UI elements (AI Overviews, FAQs)
new_features = set(new_serp['features']) - set(old_serp['features'])
if new_features:
diagnosis.append({
"type": "SNIPPET_CHANGE",
"detail": f"New SERP features detected: {', '.join(new_features)}. This pushes organic links down.",
"impact": "HIGH"
})
# B. Check Competitor Deltas
old_comps = old_serp['top_competitors']
new_comps = new_serp['top_competitors']
# Did we get pushed down?
my_rank_old = old_comps.index('Me') + 1 if 'Me' in old_comps else 10
my_rank_new = new_comps.index('Me') + 1 if 'Me' in new_comps else 10
if my_rank_new > my_rank_old:
diagnosis.append({
"type": "COMPETITOR_DELTA",
"detail": f"Rank dropped from {my_rank_old} to {my_rank_new}. Aggressive competitor activity detected.",
"impact": "CRITICAL"
})
# Did a new competitor enter?
entered = set(new_comps) - set(old_comps)
if entered:
diagnosis.append({
"type": "COMPETITOR_DELTA",
"detail": f"New competitor(s) entered top 3: {', '.join(entered)}",
"impact": "MEDIUM"
})
return diagnosis
def _calculate_cadence(self, decay_pct):
last_update = self.refresh_log.get('last_updated')
days_since_update = (datetime.now() - last_update).days if last_update else 999
# Heuristic logic for cadence
if decay_pct > 0.30:
urgency = "IMMEDIATE"
freq = "7 Days" # Weekly updates needed
elif decay_pct > 0.15:
urgency = "WARNING"
freq = "30 Days"
else:
urgency = "MONITOR"
freq = "90 Days"
return {
"urgency": urgency,
"recommended_frequency": freq,
"days_since_last_refresh": days_since_update,
"note": f"Content has not been updated for {days_since_update} days."
}
# ==========================================
# 3. EXECUTION
# ==========================================
# Setup Mock Data
gsc_data = MockDataGenerator.generate_gsc_data(decay_start_day=14, severity=0.25)
serp_data = MockDataGenerator.generate_serp_history()
content_log = {'last_updated': datetime.now() - timedelta(days=45)}
# Run Detector
detector = CTRDecayDetector(gsc_data, serp_data, content_log)
report = detector.analyze()
# Output Report
print("=== CTR DECAY DETECTION REPORT ===")
print(f"Status: {report['status']}")
print(f"Decay Magnitude: {report['decay_percentage']}")
print("-" * 30)
print("DIAGNOSTICS:")
for d in report['diagnosis']:
print(f"[{d['impact']}] {d['type']}: {d['detail']}")
print("-" * 30)
print("REFRESH CADENCE RECOMMENDATION:")
action = report['action']
print(f"Urgency: {action['urgency']}")
print(f"Suggested Update Freq: {action['recommended_frequency']}")
print(f"Context: {action['note']}")