Bto Posthog logo

Bto Posthog

Community
sonpiaz
bto-posthog

Kiểm và nâng cấp PostHog cho sản phẩm của bạn theo một chuẩn đầy đủ — cài đặt project, cách gắn SDK theo loại site, identify và reset khi đăng nhập/đăng xuất, event quan trọng, reverse proxy, và một dashboard tổng quan đặt làm trang Home để mở project là thấy hết số. Dùng khi nói "posthog", "gắn tracking", "analytics", "kiểm tracking", "event không về", "dashboard tổng quan", "mở posthog là thấy số", hoặc khi sắp launch một site cần đo người dùng. Không dùng cho tốc độ trang và Core Web Vitals chuyên sâu (dùng `bto-page-quality`), hay khi chỉ hỏi một con số lẻ trong PostHog.

Overview

Publishersonpiaz
Repositorybto-skills
Skill namebto-posthog
Stars
29
Forks
22
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by sonpiaz on GitHub. Read the source before you install it.

Installation

Install the Bto Posthog AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/sonpiaz/bto-skills/tree/main/bto-posthog
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/sonpiaz/bto-skills.git /tmp/bto-skills
mkdir -p .claude/skills
cp -r /tmp/bto-skills/bto-posthog .claude/skills/bto-posthog
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Bto Posthog in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Bto Posthog on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Bto Posthog is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

/bto-posthog

Gắn PostHog thì dễ, dán một đoạn snippet là có số. Cái khó là ba tháng sau: số bị lẫn traffic của máy dev, không biết ai là ai vì identify bằng email, nửa event bị adblock chặn, và mỗi lần muốn xem thì phải click qua năm trang. Skill này đưa bạn qua một chuẩn đầy đủ, rút từ việc kiểm bảy project PostHog đang chạy thật, rồi áp chuẩn đó cho sản phẩm của bạn.

Bốn phần: kiểm (chỉ đọc) · áp chuẩn cho project và cho code · dựng dashboard Home · đo lại để chắc số đã về đúng chỗ.

Cần có trước

  • Một project PostHog (Cloud US hoặc EU). Một sản phẩm một project: đừng gộp nhiều domain không liên quan vào một project, vì funnel, retention và bộ lọc đều tính theo project.
  • Agent đọc được PostHog: PostHog MCP (khuyên dùng) hoặc personal API key đặt trong .env, không dán vào chat. Xem bto-secrets.
  • Repo của site, nếu muốn sửa code.

Bước 1 — Kiểm (chỉ đọc, không đổi gì)

  1. Settings của project. Đọc settings rồi so với bảng ở Bước 2. Lưu ý: lệnh đọc project trả kèm project token; đừng chép token vào file báo cáo.
  2. Traffic 30 ngày theo host và SDK, một câu SQL:
    sql
    SELECT properties.$host, properties.$lib, max(properties.$lib_version),
           count(), countIf(event = '$pageview'), uniq(person_id)
    FROM events
    WHERE timestamp > now() - INTERVAL 30 DAY
    GROUP BY 1, 2 ORDER BY 4 DESC
    Thấy localhost, *.vercel.app, *.pages.dev, hay một domain lạ là phát hiện: hoặc bộ lọc chưa đủ, hoặc có site khác đang dùng nhầm key.
  3. Danh sách event 30 ngày (GROUP BY event), so với bảng event ở Bước 4.
  4. Dashboard Home hiện tại: có những tile nào, tile có bật lọc test account không. Dashboard mẫu PostHog tạo sẵn thường để tắt.
  5. Code: tìm posthog trong repo bằng chuỗi cố định (grep -rnFi), bỏ node_modules, .git, dist. Ghi lại: key lấy từ env hay viết cứng, có proxy không, identify bằng gì, có reset() khi logout không.

Kết quả: một bảng "chuẩn vs thực tế" và danh sách việc cần sửa.

Bước 2 — Áp chuẩn cho project

SettingGiá trị chuẩnVì sao
Tên + mô tả sản phẩmtên + một câuAI của PostHog và người sau hiểu project
Authorized URLs (app_urls)mọi domain productiontoolbar, heatmap mở được từ PostHog
Test account filterscohort người nội bộ + lọc host localhost, 127.0.0.1, vercel.app, pages.dev, web.apppreview và máy dev làm lệch số
Lọc test account mặc địnhbậtinsight mới tự bỏ traffic nội bộ
Timezonemột múi cho mọi project của bạn (hoặc múi của người dùng chính)so chéo không lệch ngày
Autocapture, web vitals, heatmaps, dead clicksbậtcó dữ liệu click và tốc độ trang mà không viết code
Exception autocapturebậtlỗi JS là tín hiệu rẻ nhất cho "người dùng bị vỡ"
Session replaybật, che mọi ô nhập (site riêng tư thì tắt)xem lại chỗ người dùng kẹt

Site đặt quyền riêng tư lên đầu (không cookie, ẩn IP): giữ replay tắt, không identify phía trình duyệt. Đó là lựa chọn có chủ đích, ghi rõ trong báo cáo chứ đừng "sửa" nó.

Bước 3 — Áp chuẩn cho code

js
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, { // key từ env, không viết cứng
  api_host: '/_ph',                   // reverse proxy cùng domain
  ui_host: 'https://us.posthog.com',  // đổi sang eu nếu project ở EU
  defaults: '<bản defaults mới nhất trong docs PostHog>',
  person_profiles: 'identified_only',
  capture_pageview: 'history_change', // SPA
  capture_pageleave: true,
  autocapture: true,
  capture_exceptions: true,
  session_recording: { maskAllInputs: true },
})
  • Key từ env var, thiếu thì không gửi gì. Đừng để code tự dùng một key dự phòng của project khác: đó là cách một site lặng lẽ gửi số vào nhầm project suốt nhiều tháng.
  • Reverse proxy cho khỏi bị adblock chặn. Next.js/Vercel: rewrite /_ph/static/:path* → https://us-assets.i.posthog.com/static/:path* và /_ph/:path* → https://us.i.posthog.com/:path*. Site tĩnh trên Vercel: cùng rewrite trong vercel.json. Cloudflare Pages: _redirects hoặc một Function làm proxy.
  • Identify bằng id nội bộ, không bằng email: sau khi đăng nhập xong, posthog.identify(user.id, { email, name, plan }). Đăng xuất: posthog.reset(). Đổi email không tách một người thành hai.
  • Event tiền gửi từ server (webhook thanh toán), cùng distinct_id với trình duyệt. Event không gắn người (API hit, bot) gửi kèm $process_person_profile: false để khỏi tạo người ảo.
  • Ghim version SDK trong lockfile, cập nhật có chủ đích.
  • Thêm một test: "không có env thì không có posthog.init".

Bước 4 — Event quan trọng theo loại site

Tên event snake_case, dạng object_action, một tên một ý.

Loại siteBắt buộcNên có
Landing / marketing$pageview, cta_clicked {cta, location}, signup_started, waitlist_joined hoặc checkout_startedoutbound_click
SaaS dashboarduser_signed_up, user_signed_in, onboarding_completed, một event hành động lõi, checkout_started, payment_succeeded (server)feature_used {feature}
Docs$pageview, docs_search, docs_copy_code, docs_cta_clicknút "bài này có ích?"
Khoá họclesson_viewed, lesson_completed, checkout_started, purchase_completed (server)assignment_submitted
App desktopapp_launched {version}, onboarding_completed, hành động lõi, signed_in + identify, signed_out + resetnút tắt gửi dữ liệu; không bao giờ gửi nội dung người dùng

Bước 5 — Dashboard Home: mở project là thấy số

Một dashboard tên Home — <sản phẩm> overview, đặt làm dashboard chính của project (primary_dashboard). Mọi tile bật lọc test account. Có dashboard gần đủ rồi thì thêm tile vào đó, đừng tạo bản sao.

Ví dụ bố cục cho một SaaS nhỏ:

┌─────────────────┬─────────────────┬─────────────────┐
│ Active users 30d│ Sessions 7d     │ Pageviews 7d    │   số lớn
├─────────────────┴────────┬────────┴─────────────────┤
│ DAU / WAU (line)         │ Traffic theo kênh 30d    │
├──────────────────────────┼──────────────────────────┤
│ Top pages 7d             │ Top referrers            │
├──────────────────────────┴──────────────────────────┤
│ Funnel chính: signup → hành động lõi → thanh toán   │
├──────────────────────────┬──────────────────────────┤
│ Event quan trọng 30d     │ Web vitals p75 (LCP/INP) │
├──────────────────────────┼──────────────────────────┤
│ Lỗi ($exception) + rage  │ Retention theo tuần      │
└──────────────────────────┴──────────────────────────┘

Có nhiều domain trong một project thì thêm tile "visitors theo host".

Bước 6 — Đo lại, đừng tin "đã sửa"

  1. Trong project đích: SELECT properties.$host, count() FROM events WHERE timestamp > now() - INTERVAL 1 HOUR GROUP BY 1 thấy domain thật.
  2. Nếu vừa tách project: project cũ về 0 event của domain đó sau lúc deploy.
  3. Event mới ($identify, event tự đặt, $exception) xuất hiện trong danh sách event.
  4. Mở project: trang Home đúng dashboard vừa dựng, mọi tile chạy ra số.

Báo bằng số trước và sau.

Checklist một trang

  • Một sản phẩm một project, không lẫn domain lạ
  • app_urls đủ mọi domain production
  • Lọc test account: cohort + 5 host, bật mặc định
  • Exception autocapture, dead clicks, web vitals, heatmaps bật
  • Key đọc từ env, thiếu env thì không gửi
  • Reverse proxy /_ph
  • defaults mới, version SDK ghim trong lockfile
  • identify(user.id) sau đăng nhập, reset() khi đăng xuất
  • Event tiền gửi từ server
  • Event bắt buộc theo loại site (Bước 4)
  • Dashboard Home đặt làm dashboard chính, mọi tile lọc test account
  • Đo lại sau deploy (Bước 6)

Không làm

  • Không dán API key hay project token vào chat, file báo cáo, hay commit.
  • Không xoá dashboard, insight, cohort hay dữ liệu cũ khi dọn.
  • Không bật replay hay identify trên site bạn đã chọn chế độ riêng tư.
  • Không deploy thay đổi tracking lên production mà chưa đọc diff.

Skill này phải tự tốt lên

Ba luật cho agent đang đọc file này:

  1. Eval sau mỗi lần chạy. Chấm theo checklist ở trên: bao nhiêu mục đạt trước và sau, còn mục nào người dùng phải sửa tay. Có chỗ đáng sửa thì đề xuất người dùng cập nhật thẳng vào file SKILL.md này.
  2. Thi thoảng lookup để update. PostHog đổi nhanh: bản defaults, tên setting, tên tool trong MCP. Thứ gì trong file này đã vài tháng tuổi thì kiểm lại trên docs PostHog trước khi tin.
  3. Không biết thì hỏi người. Cái gì ngoài tầm thì nói thẳng, và chỉ người dùng hỏi trong cộng đồng Build to Own (Discord của chương trình) hoặc hỏi Sơn Piaz.

Frequently asked questions

What does the Bto Posthog AI skill do?

Kiểm và nâng cấp PostHog cho sản phẩm của bạn theo một chuẩn đầy đủ — cài đặt project, cách gắn SDK theo loại site, identify và reset khi đăng nhập/đăng xuất, event quan trọng, reverse proxy, và một dashboard tổng quan đặt làm trang Home để mở project là thấy hết số. Dùng khi nói "posthog", "gắn tracking", "analytics", "kiểm tracking", "event không về", "dashboard tổng quan", "mở posthog là thấy số", hoặc khi sắp launch một site cần đo người dùng. Không dùng cho tốc độ trang và Core Web Vitals chuyên sâu (dùng `bto-page-quality`), hay khi chỉ hỏi một con số lẻ trong PostHog.

Why use Bto Posthog on TypingMind?

Because you install it once and use it with any model. Bto Posthog is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Bto Posthog in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/sonpiaz/bto-skills/tree/main/bto-posthog. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Bto Posthog?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Bto Posthog?

As many as you like. As long as a model supports skills, you can use Bto Posthog with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Bto Posthog AI skill free?

Yes. It is published on GitHub by sonpiaz under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇