@useairfoil/producer-google-analytics

中文文档
0.0.3发布于 2026/11/03TypeScriptES Module构建来源已验证

Syncs daily reports from one Google Analytics 4 property: totals, traffic sources, user acquisition, pages, landing pages, events, locations, devices, and ecommerce items. It backfills each report day by day and reads recent days again, because Google kee

原始使用文档
文档目录6 节
  1. Config
  2. Setup
  3. Data
  4. Limits
  5. Demo data
  6. Local development

Google Analytics producer

Syncs daily reports from one Google Analytics 4 property: totals, traffic sources, user acquisition, pages, landing pages, events, locations, devices, and ecommerce items. It backfills each report day by day and reads recent days again, because Google keeps updating them.

Config

VariableRequiredDefault
GA_PROPERTY_IDyesnone
GA_CLIENT_EMAILyesnone
GA_PRIVATE_KEYyesnone
GA_START_DATEno2 years ago
GA_LOOKBACK_DAYSno14

Setup

  1. In Google Cloud, enable the Google Analytics Data API for a project.
  2. Create a service account in that project. It needs no roles. Add a JSON key and download it.
  3. In Google Analytics, go to Admin > Property access management and add the service account's email as a Viewer.
  4. Set GA_CLIENT_EMAIL and GA_PRIVATE_KEY from client_email and private_key in the key file. The property ID is under Admin > Property details.

Data

  • One row per day and dimension values. The key is a JSON array of the property ID, the day, and the dimension values.
  • Days are in the property's time zone. Today is never read, since its numbers are partial.
  • Counts are long. Key events, revenue, and durations are double. Revenue is in currency_code.
  • User counts are distinct users, so they don't add up across rows or days. Use daily_overview for a day's users. Sessions, views, events, and revenue do add up.
  • (not set), (other), and empty strings are real values. Google groups rare values into (other) on large properties, and leaves out rows with few users.
  • When a later read of a day drops a row, the old row stays.
  • A change to the attribution model or other property settings changes past numbers. Backfill again to pick it up.
  • Page titles and paths can hold personal data if the site puts it there.

Limits

  • A standard property gets 200,000 tokens a day and 40,000 an hour, and 10 requests at once. The connector sends at most 5 at once. A used-up quota waits and tries again.
  • Each run reads the last GA_LOOKBACK_DAYS again, every 6 hours. Google says data can arrive up to 7 days late, and key event credit can change for 12 days.

Demo data

pnpm demo --size 8MiB writes made-up Google Analytics data without Google Analytics credentials. See the Connector Kit README for the flags and the variables it needs.

Each group is one day of every report, counting back from yesterday, for a made-up online store. It stops after two years, about 9 MiB. Traffic sources, locations, and devices add up to the day's sessions, and traffic dips at weekends.

Local development

cd connectors/producer-google-analytics
pnpm sandbox

pnpm start runs the hosted connector. It needs the Wings and PostgreSQL variables from the Connector Kit README.

版本与发布记录

@useairfoil/producer-google-analytics 共发布 4 个版本,首次发布于 2026/10/29;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.3latest2026/11/03今天
0.0.22026/10/295 天前
0.0.12026/10/295 天前
0.0.0-stage2026/10/295 天前

关于 @useairfoil/producer-google-analytics 的常见问题

@useairfoil/producer-google-analytics 是什么?

从一个谷歌Analytics 4属性同步每日报告:总数,流量来源,用户获取,页面,着陆页面,事件,位置,设备和电子商务项目。它逐日回填每个报告,并再次读取最近几天,因为谷歌保留

如何安装 @useairfoil/producer-google-analytics?

在项目目录运行 npm install @useairfoil/producer-google-analytics,或使用 pnpm add / yarn add / bun add。

@useairfoil/producer-google-analytics 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@useairfoil/producer-google-analytics 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@useairfoil/producer-google-analytics 可以商用吗?

@useairfoil/producer-google-analytics 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@useairfoil/producer-google-analytics 还在维护吗?

最新版本 0.0.3 发布于 2026/11/03(今天);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/10/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。