-
Notifications
You must be signed in to change notification settings - Fork 2.8k
MKT-74: Add blog PostHog analytics events and fix acquisition attribution #11021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add gray-matter for frontmatter parsing - Create BlogPost type and zod schema for validation - Implement PT timezone helpers (getNowPt, parsePublishTimePt) - Implement content loading (getAllBlogPosts, getBlogPostBySlug) - Implement isPublished for request-time publish gating - Add validation for frontmatter and duplicate slugs - Create content/blog directory for markdown files Closes: MKT-67
…he Past Adds the first canonical blog post to validate the content pipeline: - Title: PRDs Are Becoming Artifacts of the Past - Slug: prds-are-becoming-artifacts-of-the-past - Status: published - Publish date: 2026-01-12 at 9:00am PT Content sourced from Office Hours S01E15 with Paige Bailey. Closes: MKT-73
- Create blog index page at /blog - Use force-dynamic for request-time publish gating - Require Node.js runtime for filesystem reads - Display posts with title, description, and date - Add empty state when no posts are published - Include tags display (up to 3) Closes: MKT-68
- Create dynamic route for individual blog posts - Use force-dynamic for request-time publish gating - Require Node.js runtime for filesystem reads - Return 404 for drafts, future posts, or invalid slugs - Render Markdown with react-markdown + remark-gfm - No raw HTML rendering (safe by default) - Include consistent typography and styling Closes: MKT-69
- Add structured-data.ts with Article, CollectionPage, and BreadcrumbList schemas - Integrate JSON-LD into /blog index page (Blog collection + breadcrumbs) - Integrate JSON-LD into /blog/[slug] page (Article + post breadcrumbs) - Export structured data utilities from blog module index MKT-70
- Add analytics.ts with blog-specific tracking events: - trackBlogIndexView: Track blog index views with post count - trackBlogPostView: Track individual post views with metadata - trackBlogPostScrollDepth: Track reading progress (25%, 50%, 75%, 100%) - trackBlogPostTimeSpent: Track time spent on posts - trackBlogPostShare: Track social share clicks - trackBlogPostCTAClick: Track CTA engagement - Add BlogIndexAnalytics and BlogPostAnalytics client components - Integrate analytics into /blog and /blog/[slug] pages Attribution is handled by PostHog save_referrer and save_campaign_params. MKT-74
- Fix $pageview to include $referrer, $referring_domain, and UTM params - Track previous URL for SPA navigation referrer attribution - Rename events to blog_index_view and blog_post_view (per spec) - Add publish_time_pt property to blog_post_view - Add trackBlogSubstackClick function for use with MKT-72
All previously flagged issues have been resolved. The latest commit fixes the client-side import issue by using direct imports from
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Reviewed the blog analytics implementation. Found 1 issue related to missing data in analytics events.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| // Track time spent when component unmounts | ||
| const timeSpent = Date.now() - effectStartTime | ||
| trackBlogPostTimeSpent(post as BlogPost, timeSpent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a user navigates away from a blog post, both the visibilitychange handler (line 75-78) and this cleanup function can fire trackBlogPostTimeSpent, resulting in duplicate events. Consider adding a flag to track whether time-spent has already been recorded, or remove the tracking from one of these locations.
Fix it with Roo Code or mention @roomote and request a fix.
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Fixed the reported issues. All local checks passed. |
- Add trackedTimeSpent ref to track if time-spent event already fired - Check flag in visibilitychange handler and cleanup function - Remove duplicate interface declaration in BlogPostAnalyticsProps - Remove duplicate BlogPostAnalytics component opening tag
|
@roomote look into failing tests |
Fixed the build failure by updating |
|
🚀 Preview deployed! Your changes have been deployed to Vercel: Preview URL: https://roo-code-website-hsz8g5vgy-roo-code.vercel.app This preview will be updated automatically when you push new commits to this PR. |
Summary
Implements blog-specific PostHog analytics events and fixes acquisition attribution issues for the blog launch.
Changes
Attribution Fix (posthog-provider.tsx)
$referrerand$referring_domainto$pagevieweventsutm_source,utm_medium,utm_campaign,utm_term,utm_content) in pageview eventsdocument.referrerfor external attributionBlog Analytics Events (analytics.ts)
blog_index_view- Fired on /blog withpost_countblog_post_view- Fired on /blog/[slug] withslug,title,tags,publish_date,publish_time_ptblog_post_scroll_depth- Tracks 25%, 50%, 75%, 100% scroll milestonesblog_post_time_spent- Tracks engagement time in ms/secondsblog_substack_click- Ready for use with MKT-72 Substack linkBlog Analytics Components (blog-analytics.tsx)
BlogIndexAnalytics- Client component for /blog index trackingBlogPostAnalytics- Client component for individual post tracking with scroll depth and time spentTesting
Verification plan per issue requirements:
?utm_source=test&utm_medium=test&utm_campaign=test)Related Issues
blog_substack_clickintegration with footer linkImportant
Adds blog-specific PostHog analytics events and fixes acquisition attribution issues for the blog launch.
posthog-provider.tsx):$referrerand$referring_domainto$pageviewevents.document.referrerfor external attribution.analytics.ts):blog_index_view- Fired on /blog withpost_count.blog_post_view- Fired on /blog/[slug] withslug,title,tags,publish_date,publish_time_pt.blog_post_scroll_depth- Tracks 25%, 50%, 75%, 100% scroll milestones.blog_post_time_spent- Tracks engagement time in ms/seconds.blog_substack_click- Ready for use with MKT-72 Substack link.blog-analytics.tsx):BlogIndexAnalytics- Client component for /blog index tracking.BlogPostAnalytics- Client component for individual post tracking with scroll depth and time spent.This description was created by
for 26a47e1. You can customize this summary. It will automatically update as commits are pushed.