- Agentic Brand
- Posts
- (A Better) Agentic CRO via MCP Using PostHog
(A Better) Agentic CRO via MCP Using PostHog
AI Agent optimizes landing pages by querying PostHog's real-time data warehouse directly - no CSV exports, no ETL pipelines, just instant insights.
The Evolution: From CSV Hell to Real-Time Intelligence
A few months ago, I built an agentic CRO system using Hotjar exports, S3 buckets, and Athena queries. It worked, but it was clunky. CSV exports. Daily/weekly batches.
Then built another version of it using Microsoft Clarity that had the same issues.
Both Hotjar and Clarity provide an API but they are basic and don’t include the data we needed for our purposes. So we couldn’t use the APIs and had to rely on manual batch exports.
Then I discovered a company called PostHog that also records sessions and heatmap events. They store everything in ClickHouse (a db known for big data analytics) and expose it through a beautiful API. No more manual data exports. No more stale insights. Just real-time user behavior data that our AI agent can query instantly.
The Problem with Traditional Analytics Tools
Hotjar and Microsoft Clarity give you pretty heatmaps and session recordings, but they're walled gardens. Want to analyze 10,000 sessions programmatically? Export CSVs and pray your ETL doesn't break.
PostHog flips this. Every click, scroll, pageview, and session lives in a queryable data warehouse. Your AI agent doesn't just look at user behavior, it interrogates it with SQL-like precision.
The New Stack: Real-Time CRO Intelligence
🔹 PostHog as Data Warehouse
Session recordings with scroll depth, click coordinates, rage clicks
Events with custom properties (button clicks, form submissions, conversions)
All stored in ClickHouse, queryable via HogQL (PostHog's SQL dialect)
🔹 MCP PostHog Tools
We built custom MCP tools in our dtc.sh MCP server that expose PostHog's API:
@mcp_posthog.tool()
async def execute_hogql_query(ctx: Context, hogql_query: str) -> str:
"""Execute any HogQL query against PostHog's data warehouse"""
@mcp_posthog.tool()
async def analyze_sessions(ctx: Context, entry_pathname: str, days_back: int) -> str:
"""Compare recent vs previous period session metrics"""
@mcp_posthog.tool()
async def analyze_button_clicks(ctx: Context, entry_pathname: str) -> str:
"""Analyze click patterns for specific entry pages"""
@mcp_posthog.tool()
async def scroll_depth_analysis(ctx: Context, entry_pathname: str) -> str:
"""Track where users drop off during scroll"""
🔹 Slack + Real-Time Queries No more waiting for manual exports. CRO Agent in Slack queries live data and responds with:
Instant session analysis
Real-time scroll behavior
Click heatmap insights
Device/browser breakdowns
Conversion funnel analysis
What the Agent Can Do Now (That It Couldn't Before)
Because PostHog exposes EVERYTHING through APIs, the agent has superhuman (superagent?) analytical powers. Here are real questions you can ask:
Conversion Funnel Intelligence
"Which entry pages have bounce rates above 70%?"
SELECT
$entry_pathname,
COUNT(*) as total_sessions,
ROUND(SUM($is_bounce) / COUNT(*) * 100, 2) as bounce_rate
FROM sessions
WHERE timestamp >= now() - INTERVAL 7 DAY
GROUP BY $entry_pathname
HAVING bounce_rate > 70
ORDER BY total_sessions DESC
"How do different UTM campaigns compare in session quality?"
SELECT
$entry_utm_campaign,
COUNT(*) as sessions,
AVG($session_duration) as avg_duration,
AVG($pageview_count) as avg_pages,
ROUND(AVG($is_bounce) * 100, 2) as bounce_rate
FROM sessions
WHERE $entry_utm_campaign IS NOT NULL
GROUP BY $entry_utm_campaign
ORDER BY sessions DESC
User Experience Optimization
"Which pages load slowly and how does it affect user behavior?"
SELECT
CASE
WHEN $vitals_lcp < 2500 THEN 'Fast'
WHEN $vitals_lcp < 4000 THEN 'Medium'
ELSE 'Slow'
END as speed_category,
AVG($session_duration) as avg_duration,
ROUND(AVG($is_bounce) * 100, 2) as bounce_rate,
AVG($autocapture_count) as avg_interactions
FROM sessions
WHERE $vitals_lcp IS NOT NULL
GROUP BY speed_category
"What button texts drive the most engagement?"
SELECT
elements_chain_texts[1] as button_text,
COUNT(*) as clicks,
COUNT(DISTINCT $session_id) as unique_sessions
FROM events
WHERE event = '$autocapture'
AND elements_chain_texts[1] IS NOT NULL
GROUP BY button_text
ORDER BY clicks DESC
Traffic Source Analysis
"Which referring domains send the most qualified traffic?"
SELECT
$entry_referring_domain,
COUNT(*) as sessions,
AVG($pageview_count) as avg_pages_per_session,
AVG($session_duration) as avg_duration,
$channel_type
FROM sessions
WHERE $entry_referring_domain IS NOT NULL
GROUP BY $entry_referring_domain, $channel_type
ORDER BY avg_pages_per_session DESC
The agent writes these complex HogQL queries instantly, analyzing patterns across millions of data points in real-time. You just talk to it via plan English in a Slack channel.
Real CRO Agent in Action: Live Slack Conversation
Here's an actual conversation with the CRO Agent analyzing a live landing page in our Slack workspace, showing the real-time analytical power:
Getting the Page Source
@CRO Agent can you get the page source code for "/pages/product-offer" but don't start analysis yet.
✅ Yes, I am able to get the page source code for /pages/product-offer.The full HTML/CSS/JS has been retrieved successfully. Let me know when you'd like me to start the analysis or specify any areas of the page source you want to focus on!
Scroll Depth Analysis
@CRO Agent now analyze the scroll depth data for "/pages/product-offer" for the past 3 days
📊 Scroll Depth Analysis Results:
- Most users do not scroll past initial sections (< 50% scroll depth)
- Critical content below the fold is under-seen by majority of visitors
- Large portions of testimonials and secondary CTAs are missed
🎯 Top Priority Issues:
1. LOW OVERALL SCROLL ENGAGEMENT (High Impact)
- Move main CTA and value props above the fold
- Use sticky elements to maintain CTA visibility
2. CRITICAL CONTENT BELOW TYPICAL SCROLL DEPTH (High Impact)
- Surface trust badges and reviews much higher on page
- Test condensed versions of key elements above fold
Click Pattern Analysis
@CRO Agent now analyze clicks data for "/pages/product-offer"
for the past 3 days
🖱️ Click Analysis Results:
- 29.7% of clicks go to unlabeled/hidden buttons (major issue!)
- 22.9% of clicks wasted on cookie consent ("Accept All" + "Reject All")
- Primary CTAs only getting 5.8% and 3.9% of total clicks
- Quiz/FAQ elements absorbing significant click share
🚨 Critical Problems:
1. HIGH VOLUME OF UNLABELED BUTTON CLICKS (High Impact)
- Audit page for hidden/icon-only buttons
- Ensure all clickable elements have descriptive labels
2. COOKIE CONSENT DISTRACTING EARLY CLICKS (High Impact)
- 23% of clicks going to consent instead of conversion actions
- Test minimizing or delaying cookie consent prompt
Session Quality Analysis
@CRO Agent now analyze the sessions data for "/pages/product-offer"for the past 3 days
📈 Session Analysis Results:
- 1,626 sessions from 1,537 unique users
- 34% bounce rate (problematic for offer page)
- Only 1.2 pages per session average
- 251 sessions had slow page load (>2.5s LCP)
- Only 14.6% view more than one page
⚡ Performance Issues:
1. HIGH BOUNCE RATE + LOW MULTI-PAGE ENGAGEMENT (High Impact)
- Tighten above-the-fold offer presentation
- Add exit-intent overlays to capture bouncing users
2. PAGE LOAD TIMES DRAGGING ENGAGEMENT (High Impact)
- 15% of sessions experiencing slow load times
- Optimize images and defer non-critical JavaScript
Comprehensive CRO Recommendations
@CRO Agent now take a look at that page source code again and combine your learnings from all of this analysis and make some recommendations based on CRO best practices
🎯 HIGH-IMPACT A/B TEST OPPORTUNITIES:
1. MAKE CORE VALUE ULTRA-CLEAR ABOVE FOLD (High Confidence)
- Reduce hero section clutter drastically
- Single strong headline + one CTA + trust badge
- Show "Save 67% Today" prominently on load
2. UNIFY AND SIMPLIFY THE CTAS (High Confidence)
- Too many similar CTA buttons causing decision friction
- Combine all offers into one best-value deal
- One prominent main CTA above fold + sticky version
3. MINIMIZE COOKIE CONSENT DISTRACTION (High Confidence)
- 23% of clicks going to unnecessary consent instead of conversions (GDPR popup not required in the US)
- Shrink, reposition, or delay cookie consent popup
4. ENHANCE SCROLL CUES (Medium Confidence)
- Add animated scroll indicators ("↓ See How It Works")
- Show teaser of content below fold
- Use progressive "step 1/2/3" visual indicators
5. FIX UNLABELED BUTTON PROBLEM (High Confidence)
- 29.7% of clicks going to mystery elements
- Review all clickable icons for accessible text labels
- Remove buggy or hidden interaction elements
Expected Impact: 15-40% conversion rate improvement based on addressing these fundamental CRO principles.
This live conversation demonstrates how the PostHog-powered CRO Agent provides:
🔥 Instant Multi-Dimensional Analysis
Scroll behavior patterns in real-time
Click distribution across all page elements
Session quality metrics with performance data
Page source code inspection
🎯 Actionable, Prioritized Recommendations
Problems ranked by impact and confidence level
Specific A/B test ideas with expected outcomes
Technical solutions for immediate implementation
📊 Data-Driven Insights
Quantified user behavior (29.7% mystery clicks, 34% bounce rate)
Performance bottlenecks (251 slow-loading sessions)
Conversion funnel friction points identified
The agent combines PostHog's granular event data with CRO expertise to deliver insights that would typically require hours of manual analysis - all in real-time through a simple Slack conversation.
Actionable Questions Your CRO Agent Can Answer
With PostHog's rich data structure, here are impactful questions you can ask your agent:
🔍 Performance Diagnostics
"Which entry pages have the worst Core Web Vitals scores?"
"How does page load speed correlate with session duration?"
"Which traffic sources bring users who spend the most time on site?"
"What's the optimal session duration that indicates buying intent?"
"Are US users interacting with unnecessary GDPR popups?"
📊 Conversion Intelligence
"Which UTM campaigns generate the highest-value sessions?"
"How do organic vs paid visitors behave differently?"
"Which referring domains send traffic that actually converts?"
"What's the correlation between page views and conversion probability?"
"How many users are wasting clicks on compliance elements that don't apply to them?"
🎯 Element Optimization
"Which button texts get clicked most vs least?"
"What DOM elements are users completely ignoring?"
"Which form fields cause the highest drop-off rates?"
"How do different CTA placements perform across device types?"
"What percentage of user clicks are going to non-conversion elements?"
🛣️ User Journey Analysis
"What's the typical path from landing page to conversion?"
"Which exit pages indicate friction points?"
"How many page views do converting users typically have?"
"Which content keeps users engaged longest?"
"Are users getting distracted by regulatory popups instead of engaging with core content?"
⚡ Real-Time Alerts
"Show me pages with bounce rates above 70% this week"
"Which campaigns are underperforming compared to last month?"
"Alert me to any sudden drops in session quality"
"Identify pages that need immediate optimization attention"
"Flag any unnecessary friction elements affecting specific geographic regions"
Why PostHog + MCP Is Superior
Immediate Insights: No waiting for overnight exports. Query live data and get answers in seconds.
Infinite Flexibility: Not limited to pre-built reports. The agent writes custom HogQL queries for any question.
Session-Level Detail: Access individual session details, scroll maps, and click coordinates through the API.
Real-Time Optimization: Test changes and see results immediately, not tomorrow.
No Data Engineering: No ETL pipelines, S3 buckets, or Athena tables. Just API calls.
The Future of CRO
This is a new category of optimization.
Traditional CRO: Look at dashboards → Make guesses → A/B test → Wait weeks for results
Agentic CRO: Query behavior → Identify patterns → Generate solutions → Deploy code → Measure impact
The agent becomes your optimization team:
Data Analyst: Writes complex queries to understand user behavior
UX Researcher: Identifies friction points and user journey issues
Designer: Proposes layout changes based on interaction patterns
Developer: Rewrites page code with optimizations
Growth Marketer: Tracks conversion impact and suggests iterations
Getting Started
If you're running PostHog (or considering it), you can build similar MCP tools to unlock agentic CRO:
Set up PostHog with session recordings and custom events
Build MCP server that expose PostHog's query API
Connect PostHog to your MCP server
Start asking questions about your user behavior data
Let the agent propose and implement optimizations
or
Let a.gentic handle the whole thing for you.
Want a.gentic to set you up with a PostHog based CRO Agent? DM Bora on LinkedIn.