analytics-best-practices

v2026.09.24

Track custom events and conversions with Vercel Web Analytics via the track() call. Use when instrumenting user actions, conversions, or form submissions.

GitHub
安装命令
npx skhub add andrelandgraf/analytics-best-practices
Markdown
SKILL.md

Analytics Best Practices

Track custom events and conversions with Vercel Web Analytics.

Prerequisites

Complete these setup recipes first:

  • Vercel Web Analytics

Tracking Events

Call track(name) or track(name, properties) from client code.

import { track } from "@vercel/analytics";

track("signup_clicked");

track("purchase_completed", { plan: "pro", price: 29, currency: "USD" });

Name events consistently around auth, feature usage, and conversions.

track("signup_completed", { method: "email" });
track("chat_completed", { messageCount: 5 });
track("subscription_created", { plan: "pro" });
track("upgrade_completed", { from: "free", to: "pro" });

In Components

Track inside event handlers.

import { track } from "@vercel/analytics";

function UpgradeButton() {
  return (
    <button
      onClick={() => track("upgrade_button_clicked", { location: "header" })}
    >
      Upgrade
    </button>
  );
}
function ContactForm() {
  const handleSubmit = async (e: FormEvent) => {
    e.preventDefault();
    track("contact_form_submitted", { source: "footer" });
    // submit...
  };

  return <form onSubmit={handleSubmit}>...</form>;
}

Testing in Development

Events only send in production by default. Enable locally on the <Analytics /> component in layout.tsx.

<Analytics mode="development" />  // sends events
<Analytics debug />               // logs events to console

View page views, visitors, and custom events under Analytics in the Vercel dashboard.


References

发现
标签

此技能尚未发布标签。

版本
最新版本元数据

版本

v2026.09.24

发布时间

2026年9月24日

分类

未分类

许可证

未指定

源路径

skills/analytics-best-practices

默认分支

main

最新提交

4449331

Tree SHA

1f78782