datafast

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

When to Use This Skill

何时使用该工具

  • You need to instrument a website (static, SPA, Next.js, Astro, etc.) with DataFast tracking.
  • Revenue needs to be attributed to marketing channels (Stripe, LemonSqueezy, Polar, custom providers).
  • You want to record custom events/goals reliably despite ad blockers.
  • You must proxy the tracker/script for increased data quality or hashed navigation.
  • You want to export/import historical analytics or query DataFast APIs.
  • 您需要为网站(静态站点、SPA、Next.js、Astro等)部署DataFast跟踪功能。
  • 需要将收入归因到营销渠道(Stripe、LemonSqueezy、Polar、自定义提供商)。
  • 您希望在存在广告拦截器的情况下仍能可靠记录自定义事件/目标。
  • 必须代理跟踪器/脚本以提升数据质量或适配哈希路由。
  • 您需要导出/导入历史分析数据,或调用DataFast API。

Quickstart (4 steps)

快速开始(4步)

  1. Install the tracking script inside
    <head>
    :
    html
    <script
      defer
      data-website-id="dfid_XXXX"
      data-domain="example.com"
      src="https://datafa.st/js/script.js"
    ></script>
    • Customize via
      data-allow-localhost
      ,
      data-api-url
      ,
      data-debug
      ,
      data-allowed-hostnames
      ,
      data-disable-console
      ,
      data-allow-file-protocol
      .
    • Include the
      datafast-queue
      snippet to queue calls that happen before the library loads.
  2. Connect payment providers (Stripe, LemonSqueezy, Polar, Shopify, etc.) from the Revenue tab so DataFast auto-tracks revenue.
  3. Add custom goals/events with
    window.datafast("my_goal")
    ,
    data-fast-goal
    attributes, or the server-side Goals API.
  4. Optional proxy to bypass ad blockers: rewrite
    /js/script.js
    and
    /api/events
    to your domain and forward visitor IP with
    x-datafast-real-ip
    .
  1. <head>
    中安装跟踪脚本
    :
    html
    <script
      defer
      data-website-id="dfid_XXXX"
      data-domain="example.com"
      src="https://datafa.st/js/script.js"
    ></script>
    • 可通过
      data-allow-localhost
      data-api-url
      data-debug
      data-allowed-hostnames
      data-disable-console
      data-allow-file-protocol
      进行自定义配置。
    • 加入
      datafast-queue
      代码片段,以在库加载前对调用进行排队。
  2. 连接支付提供商(Stripe、LemonSqueezy、Polar、Shopify等):从收入选项卡进行配置,DataFast将自动跟踪收入数据。
  3. 添加自定义目标/事件:使用
    window.datafast("my_goal")
    data-fast-goal
    属性,或通过服务端Goals API实现。
  4. 可选代理配置以绕过广告拦截器:将
    /js/script.js
    /api/events
    重写到您的域名下,并通过
    x-datafast-real-ip
    传递访客IP。

Installation Reference

安装参考

  • Scripts load via
    <Script />
    components in frameworks (Next.js App Router, React, Vue, Astro, etc.) or declaratively in
    public/index.html
    .
  • For hash-based navigation, use the hash-enabled script
    https://datafa.st/js/script.hash.js
    .
  • Use GTM, Shopify, Webflow, Wix, Podia, Kajabi, Ghost, Bubble, Framer, Astro, React Router, Laravel, Django, FastAPI, Flask, Express, PHP, Nginx, Firebase, Rocket, etc., by dropping the same script into the
    <head>
    or platform-specific head/custom code sections.
  • 可通过框架中的
    <Script />
    组件(Next.js App Router、React、Vue、Astro等)或在
    public/index.html
    中声明式加载脚本。
  • 对于基于哈希的路由,使用支持哈希的脚本
    https://datafa.st/js/script.hash.js
  • 可在GTM、Shopify、Webflow、Wix、Podia、Kajabi、Ghost、Bubble、Framer、Astro、React Router、Laravel、Django、FastAPI、Flask、Express、PHP、Nginx、Firebase、Rocket等平台中使用,只需将相同的脚本添加到
    <head>
    或平台特定的头部/自定义代码区域即可。

Revenue Attribution Best Practices

收入归因最佳实践

  • After the tracking script is live, go to Website Settings → Revenue and add each payment provider.
  • Always pass
    datafast_visitor_id
    (and optionally
    datafast_session_id
    ) when creating checkout sessions:
    • Stripe Checkout / PaymentIntent: read the cookies from
      cookies()
      or
      request.cookies
      and add them to
      metadata
      .
    • LemonSqueezy: include DataFast cookies under
      custom
      .
    • Polar: add cookies to
      metadata
      .
    • Paddle / Dodo Payments / Easytool / Custom: call the Payments API or trigger a
      payment
      goal with the customer email.
  • For gateways where DataFast already pulls revenue (Shopify, Stripe, LemonSqueezy, Polar), keep the tracking snippet installed but omit redundant manual events.
  • Document the metadata mapping and ensure downstream jobs read
    datafast_visitor_id
    for each financial event.
  • 跟踪脚本上线后,进入网站设置 → 收入并添加每个支付提供商。
  • 创建结账会话时,务必传递
    datafast_visitor_id
    (可选
    datafast_session_id
    ):
    • Stripe Checkout / PaymentIntent:从
      cookies()
      request.cookies
      中读取Cookie,并添加到
      metadata
      中。
    • LemonSqueezy:在
      custom
      字段下包含DataFast Cookie。
    • Polar:将Cookie添加到
      metadata
      中。
    • Paddle / Dodo Payments / Easytool / 自定义提供商:调用Payments API或触发包含客户邮箱的
      payment
      目标。
  • 对于DataFast已自动拉取收入数据的网关(Shopify、Stripe、LemonSqueezy、Polar),保留跟踪代码片段,但无需添加重复的手动事件。
  • 记录元数据映射关系,并确保下游任务为每个财务事件读取
    datafast_visitor_id

Custom Events & Goals

自定义事件与目标

Method 1 –
window.datafast()
(client-side)

方法1 –
window.datafast()
(客户端)

  • Fire
    window?.datafast("goal_name")
    on clicks, success pages, or after API responses.
  • Record parameters:
    window.datafast("checkout", { price: "49", plan: "pro" })
    .
  • 在点击事件、成功页面或API响应完成后触发
    window?.datafast("goal_name")
  • 记录参数:
    window.datafast("checkout", { price: "49", plan: "pro" })

Method 2 – HTML data attributes

方法2 – HTML数据属性

  • Add
    data-fast-goal="goal_name"
    to buttons/links.
  • Enrich with
    data-fast-goal-*
    attributes (
    data-fast-goal-price="49"
    becomes
    { price: "49" }
    ).
  • 为按钮/链接添加
    data-fast-goal="goal_name"
    属性。
  • 通过
    data-fast-goal-*
    属性丰富数据(
    data-fast-goal-price="49"
    将转换为
    { price: "49" }
    )。

Method 3 – Server-side Goals API

方法3 – 服务端Goals API

  • POST to
    https://datafa.st/api/v1/goals
    with
    datafast_visitor_id
    ,
    name
    , and optional
    metadata
    .
  • Authenticate with
    Authorization: Bearer YOUR_API_KEY
    .
  • Ensure the visitor already had at least one pageview (tracked via the script).
  • https://datafa.st/api/v1/goals
    发送POST请求,携带
    datafast_visitor_id
    name
    及可选的
    metadata
  • 使用
    Authorization: Bearer YOUR_API_KEY
    进行身份验证。
  • 确保访客已至少有一次页面浏览记录(通过脚本跟踪)。

Funnels, Scrolls, & Filters

转化漏斗、滚动跟踪与筛选器

  • Use
    data-fast-scroll
    on critical sections (features, pricing, testimonials) to send scroll goals when 50% of the element is visible.
  • Combine scroll goals with funnels (
    landing page visit → feature scroll → CTA click
    ) to spot drop-offs.
  • Track UTM/ref/via parameters automatically tracked by DataFast; encourage marketing links to include
    ?ref=
    ,
    ?utm_source=
    ,
    ?utm_medium=
    ,
    ?utm_campaign=
    ,
    ?utm_term=
    , and
    ?utm_content
    .
  • Use filters to slice by country, device, campaign, URL path, or custom goals; hover charts expose filter shortcuts.
  • Provide docs for
    datafast_ignore
    localStorage to exclude internal traffic.
  • 在关键区域(功能介绍、定价、客户评价)使用
    data-fast-scroll
    属性,当元素50%可见时发送滚动目标事件。
  • 将滚动目标与转化漏斗(着陆页访问 → 功能区域滚动 → CTA点击)结合使用,定位流失节点。
  • DataFast会自动跟踪UTM/ref/via参数;建议营销链接包含
    ?ref=
    ?utm_source=
    ?utm_medium=
    ?utm_campaign=
    ?utm_term=
    ?utm_content
  • 使用筛选器按国家、设备、营销活动、URL路径或自定义目标拆分数据;悬停图表可显示筛选快捷方式。
  • 提供
    datafast_ignore
    localStorage的使用文档,用于排除内部流量。

Proxy & Hosting Guidance

代理与托管指南

  • Proxy requests so the script loads from
    /js/script.js
    and events post to
    /api/events
    on your domain.
  • Forward the visitor IP with
    x-datafast-real-ip
    to keep geolocation accurate.
  • Next.js rewrites, Express HTTP proxy, Flask/FastAPI routes, PHP scripts, Nginx/Caddy rules, Firebase Functions, and DigitalOcean/Nginx examples are ready-made patterns—adapt whichever matches your stack.
  • Allowlist additional domains via
    data-allowed-hostnames="app.io,shop.example.com"
    and set
    data-domain
    to the root domain to share cookies across subdomains.
  • Use
    data-api-url
    or
    datafast_events
    endpoints when custom routing is needed; the tracker auto-detects proxied setups.
  • 代理请求,使脚本从您域名下的
    /js/script.js
    加载,事件提交到
    /api/events
  • 通过
    x-datafast-real-ip
    传递访客IP,以保持地理位置数据的准确性。
  • 已提供Next.js重写、Express HTTP代理、Flask/FastAPI路由、PHP脚本、Nginx/Caddy规则、Firebase Functions及DigitalOcean/Nginx的现成配置示例,可根据您的技术栈进行适配。
  • 通过
    data-allowed-hostnames="app.io,shop.example.com"
    添加允许的域名列表,并将
    data-domain
    设置为根域名,以在子域名间共享Cookie。
  • 当需要自定义路由时,使用
    data-api-url
    datafast_events
    端点;跟踪器会自动检测代理配置。

API & Export/Import

API与导出/导入

  • DataFast APIs (Overview, Timeseries, Devices, Pages, Countries, Referrers, Campaigns, Goals, Payments, Visitors, Metadata, Realtime) all require
    Authorization: Bearer <API_KEY>
    .
  • Use the Payments API to push revenue from unsupported providers: include
    amount
    ,
    currency
    ,
    transaction_id
    , and the visitor ID.
  • Use the Goals API for server-side events (max 10 metadata keys).
  • Import Plausible exports into DataFast to keep historical data; reference
    Import your Plausible data
    .
  • Export to dashboards via the API Playground, Real-time endpoints, or custom scripts.
  • 所有DataFast API(概览、时间序列、设备、页面、国家、引荐来源、营销活动、目标、支付、访客、元数据、实时数据)均需使用
    Authorization: Bearer <API_KEY>
    进行身份验证。
  • 使用Payments API从不受支持的提供商推送收入数据:需包含
    amount
    currency
    transaction_id
    及访客ID。
  • 使用Goals API处理服务端事件(最多支持10个元数据键)。
  • 将Plausible导出的数据导入DataFast,以保留历史数据;可参考「导入您的Plausible数据」文档。
  • 通过API playground、实时端点或自定义脚本将数据导出到仪表板。

Mobile & Support

移动端与支持

  • Install the DataFast mobile app (iOS/Android) to monitor metrics on the go; connect any site with an API key.
  • Use Google Search Console integration for keyword influence; ensure your domain is verified and you have owner/full permissions.
  • Track GitHub commits in your dashboard to correlate releases with revenue spikes.
  • Reach out to
    marc@datafa.st
    or
    https://feedback.datafa.st/
    for help, feature requests, or troubleshooting.
  • 安装DataFast移动端应用(iOS/Android),随时随地监控指标;使用API密钥连接任意站点。
  • 集成Google Search Console以分析关键词影响;确保您的域名已验证,且拥有所有者/完全权限。
  • 在仪表板中跟踪GitHub提交记录,关联版本发布与收入峰值。
  • 如有问题、功能请求或故障排查需求,可联系
    marc@datafa.st
    或访问
    https://feedback.datafa.st/

Troubleshooting Checklist

故障排查清单

  • Script not firing headers? Confirm the tag is inside
    <head>
    and the
    data-website-id
    domain matches
    data-domain
    .
  • No revenue? Verify payment provider connection plus metadata cookies in Stripe/LemonSqueezy/Polar sessions.
  • Goals not recorded? Ensure goal names use lowercase/underscores/hyphens and do not exceed 64 characters.
  • Vercel preview showing no data? Enable
    data-allow-localhost="true"
    during staging or rely on proxied script in production.
  • Proxy showing all visitors from server IP? Add
    x-datafast-real-ip
    or forward
    X-Forwarded-For
    .
  • 脚本未触发请求?确认标签位于
    <head>
    内,且
    data-website-id
    对应的域名与
    data-domain
    匹配。
  • 无收入数据?验证支付提供商已连接,且Stripe/LemonSqueezy/Polar会话中包含元数据Cookie。
  • 目标未被记录?确保目标名称使用小写/下划线/连字符,且长度不超过64个字符。
  • Vercel预览环境无数据?在 staging 阶段启用
    data-allow-localhost="true"
    ,或在生产环境使用代理脚本。
  • 代理显示所有访客均来自服务器IP?添加
    x-datafast-real-ip
    或转发
    X-Forwarded-For

References

参考资料

  • Script configuration reference:
    data-allowed-hostnames
    ,
    data-api-url
    ,
    data-allow-localhost
    ,
    data-disable-console
    ,
    data-debug
    .
  • Revenue attribution guides (Stripe Checkout, PaymentIntent, Checkout Links, LemonSqueezy, Polar, Paddle, Dodo Payments, Easytool).
  • Technology-specific install docs for Shopify, Webflow, Wix, Ghost, Next.js, Astro, Laravel, React Router, Firebase, Astro middleware, Caddy, Nginx, DigitalOcean, etc.
  • 脚本配置参考:
    data-allowed-hostnames
    data-api-url
    data-allow-localhost
    data-disable-console
    data-debug
  • 收入归因指南(Stripe Checkout、PaymentIntent、结账链接、LemonSqueezy、Polar、Paddle、Dodo Payments、Easytool)。
  • 特定技术的安装文档:Shopify、Webflow、Wix、Ghost、Next.js、Astro、Laravel、React Router、Firebase、Astro中间件、Caddy、Nginx、DigitalOcean等。