google-analytics

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Google Analytics Skill

Google Analytics 技能

Track website and app analytics with Google Analytics 4's comprehensive platform.
借助Google Analytics 4的综合平台追踪网站与应用的分析数据。

Quick Install

快速安装

bash
curl -sSL https://canifi.com/skills/google-analytics/install.sh | bash
Or manually:
bash
cp -r skills/google-analytics ~/.canifi/skills/
bash
curl -sSL https://canifi.com/skills/google-analytics/install.sh | bash
或者手动安装:
bash
cp -r skills/google-analytics ~/.canifi/skills/

Setup

设置

Configure via canifi-env:
bash
undefined
通过canifi-env进行配置:
bash
undefined

First, ensure canifi-env is installed:

首先,确保已安装canifi-env:

canifi-env set GOOGLE_ANALYTICS_PROPERTY_ID "your_property_id" canifi-env set GOOGLE_CLIENT_ID "your_client_id" canifi-env set GOOGLE_CLIENT_SECRET "your_client_secret" canifi-env set GOOGLE_REFRESH_TOKEN "your_refresh_token"
undefined
canifi-env set GOOGLE_ANALYTICS_PROPERTY_ID "your_property_id" canifi-env set GOOGLE_CLIENT_ID "your_client_id" canifi-env set GOOGLE_CLIENT_SECRET "your_client_secret" canifi-env set GOOGLE_REFRESH_TOKEN "your_refresh_token"
undefined

Privacy & Authentication

隐私与认证

Your credentials, your choice. Canifi LifeOS respects your privacy.
你的凭证,由你掌控。 Canifi LifeOS尊重你的隐私。

Option 1: Manual Browser Login (Recommended)

选项1:手动浏览器登录(推荐)

If you prefer not to share credentials with Claude Code:
  1. Complete the Browser Automation Setup using CDP mode
  2. Login to the service manually in the Playwright-controlled Chrome window
  3. Claude will use your authenticated session without ever seeing your password
如果你不想与Claude Code共享凭证:
  1. 使用CDP模式完成浏览器自动化设置
  2. 在Playwright控制的Chrome窗口中手动登录该服务
  3. Claude将使用你的已认证会话,全程不会获取你的密码

Option 2: Environment Variables

选项2:环境变量

If you're comfortable sharing credentials, you can store them locally:
bash
canifi-env set SERVICE_EMAIL "your-email"
canifi-env set SERVICE_PASSWORD "your-password"
Note: Credentials stored in canifi-env are only accessible locally on your machine and are never transmitted.
如果你愿意共享凭证,可以将其存储在本地:
bash
canifi-env set SERVICE_EMAIL "your-email"
canifi-env set SERVICE_PASSWORD "your-password"
注意:存储在canifi-env中的凭证仅能在你的本地机器上访问,绝不会被传输。

Capabilities

功能特性

  1. Traffic Analysis: Monitor website traffic, sources, and user behavior
  2. Conversion Tracking: Track goals, events, and e-commerce conversions
  3. Audience Insights: Understand user demographics and interests
  4. Real-time Data: View live user activity on your properties
  5. Custom Reports: Create custom reports and explorations
  1. 流量分析:监控网站流量、来源及用户行为
  2. 转化追踪:追踪目标、事件及电商转化
  3. 受众洞察:了解用户的人口统计特征与兴趣偏好
  4. 实时数据:查看你的属性上的实时用户活动
  5. 自定义报告:创建自定义报告与探索分析

Usage Examples

使用示例

Get Traffic Overview

获取流量概览

User: "Show me website traffic for the last 7 days"
Assistant: Returns sessions, users, and pageviews
用户:“展示过去7天的网站流量数据”
助手:返回会话数、用户数和页面浏览量

View Top Pages

查看热门页面

User: "What are my top performing pages?"
Assistant: Returns pages by views and engagement
用户:“我表现最好的页面有哪些?”
助手:按浏览量和互动度返回页面列表

Check Conversions

查看转化数据

User: "How many conversions did we get this month?"
Assistant: Returns conversion counts by goal
用户:“我们这个月有多少转化?”
助手:按目标返回转化数量

Real-time Users

实时用户数据

User: "How many users are on the site right now?"
Assistant: Returns real-time user count and activity
用户:“现在网站上有多少用户?”
助手:返回实时用户数量及活动情况

Authentication Flow

认证流程

  1. Create project in Google Cloud Console
  2. Enable Analytics API
  3. Set up OAuth 2.0 credentials
  4. Implement authorization code flow
  1. 在Google Cloud Console中创建项目
  2. 启用Analytics API
  3. 设置OAuth 2.0凭证
  4. 实现授权码流程

Error Handling

错误处理

ErrorCauseSolution
401 UnauthorizedToken expiredRefresh access token
403 ForbiddenNo property accessCheck permissions
404 Not FoundInvalid property IDVerify property ID
429 Rate LimitedQuota exceededWait for quota reset
错误原因解决方案
401 Unauthorized令牌过期刷新访问令牌
403 Forbidden无属性访问权限检查权限设置
404 Not Found属性ID无效验证属性ID
429 Rate Limited配额超出等待配额重置

Notes

注意事项

  • GA4 is the current version
  • Universal Analytics deprecated
  • Free tier with data limits
  • BigQuery export available
  • Custom dimensions supported
  • Audience export to Google Ads
  • GA4为当前版本
  • Universal Analytics已废弃
  • 免费版有数据限制
  • 支持BigQuery导出
  • 支持自定义维度
  • 可将受众数据导出至Google Ads