google-analytics

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Google Analytics Analysis

Google Analytics 数据分析

Analyze website performance using Google Analytics data to provide actionable insights and improvement recommendations.
使用Google Analytics数据分析网站性能,提供可执行的洞察和改进建议。

Quick Start

快速开始

1. Setup Authentication

1. 设置身份验证

This Skill requires Google Analytics API credentials. Set up environment variables:
bash
export GOOGLE_ANALYTICS_PROPERTY_ID="your-property-id"
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
Or create a
.env
file in your project root:
env
GOOGLE_ANALYTICS_PROPERTY_ID=123456789
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
Never commit credentials to version control. The service account JSON file should be stored securely outside your repository.
本Skill需要Google Analytics API凭据。设置环境变量:
bash
export GOOGLE_ANALYTICS_PROPERTY_ID="your-property-id"
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
或者在项目根目录创建
.env
文件:
env
GOOGLE_ANALYTICS_PROPERTY_ID=123456789
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
切勿将凭据提交到版本控制系统中。 服务账户JSON文件应安全存储在代码仓库之外。

2. Install Required Packages

2. 安装所需包

bash
undefined
bash
undefined

Option 1: Install from requirements file (recommended)

选项1:从requirements文件安装(推荐)

pip install -r cli-tool/components/skills/analytics/google-analytics/requirements.txt
pip install -r cli-tool/components/skills/analytics/google-analytics/requirements.txt

Option 2: Install individually

选项2:单独安装

pip install google-analytics-data python-dotenv pandas
undefined
pip install google-analytics-data python-dotenv pandas
undefined

3. Analyze Your Project

3. 分析你的项目

Once configured, I can:
  • Review current traffic and user behavior metrics
  • Identify top-performing and underperforming pages
  • Analyze traffic sources and conversion funnels
  • Compare performance across time periods
  • Suggest data-driven improvements
配置完成后,我可以:
  • 查看当前流量和用户行为指标
  • 识别表现最佳和不佳的页面
  • 分析流量来源和转化漏斗
  • 对比不同时间段的性能
  • 提出基于数据的改进建议

How to Use

使用方法

Ask me questions like:
  • "Review our Google Analytics performance for the last 30 days"
  • "What are our top traffic sources?"
  • "Which pages have the highest bounce rates?"
  • "Analyze user engagement and suggest improvements"
  • "Compare this month's performance to last month"
可以向我提出如下问题:
  • "查看我们过去30天的Google Analytics性能数据"
  • "我们的主要流量来源有哪些?"
  • "哪些页面的跳出率最高?"
  • "分析用户参与度并提出改进建议"
  • "对比本月与上月的性能表现"

Analysis Workflow

分析流程

When you ask me to analyze Google Analytics data, I will:
  1. Connect to the API using the helper script
  2. Fetch relevant metrics based on your question
  3. Analyze the data looking for:
    • Traffic trends and patterns
    • User behavior insights
    • Performance bottlenecks
    • Conversion opportunities
  4. Provide recommendations with:
    • Specific improvement suggestions
    • Priority level (high/medium/low)
    • Expected impact
    • Implementation guidance
当你要求我分析Google Analytics数据时,我会:
  1. 连接到API:使用辅助脚本连接
  2. 获取相关指标:根据你的问题获取对应指标
  3. 分析数据:重点关注:
    • 流量趋势和模式
    • 用户行为洞察
    • 性能瓶颈
    • 转化机会
  4. 提供建议:包含:
    • 具体的改进建议
    • 优先级(高/中/低)
    • 预期影响
    • 实施指导

Common Metrics

常见指标

For detailed metric definitions and dimensions, see REFERENCE.md.
有关指标定义和维度的详细信息,请查看REFERENCE.md

Traffic Metrics

流量指标

  • Sessions, Users, New Users
  • Page views, Screens per Session
  • Average Session Duration
  • 会话数、用户数、新用户数
  • 页面浏览量、每次会话屏幕数
  • 平均会话时长

Engagement Metrics

参与度指标

  • Bounce Rate, Engagement Rate
  • Event Count, Conversions
  • Scroll Depth, Click-through Rate
  • 跳出率、参与率
  • 事件数、转化数
  • 滚动深度、点击率

Acquisition Metrics

获客指标

  • Traffic Source/Medium
  • Campaign Performance
  • Channel Grouping
  • 流量来源/媒介
  • 广告系列表现
  • 渠道分组

Conversion Metrics

转化指标

  • Goal Completions
  • E-commerce Transactions
  • Conversion Rate by Source
  • 目标完成数
  • 电商交易数
  • 按来源划分的转化率

Analysis Examples

分析示例

For complete analysis patterns and use cases, see EXAMPLES.md.
有关完整的分析模式和用例,请查看EXAMPLES.md

Scripts

脚本

The Skill includes utility scripts for API interaction:
本Skill包含用于API交互的实用脚本:

Fetch Current Performance

获取当前性能数据

bash
python scripts/ga_client.py --days 30 --metrics sessions,users,bounceRate
bash
python scripts/ga_client.py --days 30 --metrics sessions,users,bounceRate

Analyze and Generate Report

分析并生成报告

bash
python scripts/analyze.py --period last-30-days --compare previous-period
The scripts handle API authentication, data fetching, and basic analysis. I'll interpret the results and provide actionable recommendations.
bash
python scripts/analyze.py --period last-30-days --compare previous-period
这些脚本负责API身份验证、数据获取和基础分析。我会解读结果并提供可执行的建议。

Troubleshooting

故障排除

Authentication Error: Verify that:
  • GOOGLE_APPLICATION_CREDENTIALS
    points to a valid service account JSON file
  • The service account has "Viewer" access to your GA4 property
  • GOOGLE_ANALYTICS_PROPERTY_ID
    matches your GA4 property ID (not the measurement ID)
No Data Returned: Check that:
  • The property ID is correct (find it in GA4 Admin > Property Settings)
  • The date range contains data
  • The service account has been granted access in GA4
Import Errors: Install required packages:
bash
pip install google-analytics-data python-dotenv pandas
身份验证错误:请验证:
  • GOOGLE_APPLICATION_CREDENTIALS
    指向有效的服务账户JSON文件
  • 服务账户拥有GA4媒体资源的“查看者”权限
  • GOOGLE_ANALYTICS_PROPERTY_ID
    与你的GA4媒体资源ID匹配(而非测量ID)
无数据返回:检查:
  • 媒体资源ID是否正确(可在GA4管理员>媒体资源设置中找到)
  • 日期范围包含数据
  • 服务账户已在GA4中获得访问权限
导入错误:安装所需包:
bash
pip install google-analytics-data python-dotenv pandas

Security Notes

安全说明

  • Never hardcode API credentials or property IDs in code
  • Store service account JSON files outside version control
  • Use environment variables or
    .env
    files for configuration
  • Add
    .env
    and credential files to
    .gitignore
  • Rotate service account keys periodically
  • Use least-privilege access (Viewer role only)
  • 切勿硬编码API凭据或媒体资源ID
  • 将服务账户JSON文件存储在代码仓库之外
  • 使用环境变量或
    .env
    文件进行配置
  • .env
    和凭据文件添加到
    .gitignore
  • 定期轮换服务账户密钥
  • 使用最小权限访问(仅授予查看者角色)

Data Privacy

数据隐私

This Skill accesses aggregated analytics data only. It does not:
  • Access personally identifiable information (PII)
  • Store analytics data persistently
  • Share data with external services
  • Modify your Google Analytics configuration
All data is processed locally and used only to generate recommendations during the conversation.
本Skill仅访问聚合分析数据,不会:
  • 访问个人身份信息(PII)
  • 持久化存储分析数据
  • 与外部服务共享数据
  • 修改你的Google Analytics配置
所有数据均在本地处理,仅用于在对话过程中生成建议。