返回顶部
g

google-analytics谷歌分析

|

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.10
安全检测
已通过
8,178
下载量
免费
免费
18
收藏
概述
安装方式
版本历史

google-analytics

Google Analytics

通过托管的OAuth认证访问Google Analytics。本技能涵盖管理API(管理账户、媒体资源、数据流)和数据API(运行指标报告)。

快速开始

bash

列出账户摘要(管理API)


python < import urllib.request, os, json
req = urllib.request.Request(https://gateway.maton.ai/google-analytics-admin/v1beta/accountSummaries)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

运行报告(数据API)

python <header(Authorization, fBearer {os.environ[MATONAPI_KEY]}) req.add_header(Content-Type, application/json) print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF

基础URL

管理API(管理账户、媒体资源、数据流):

https://gateway.maton.ai/google-analytics-admin/{native-api-path}

数据API(运行报告):

https://gateway.maton.ai/google-analytics-data/{native-api-path}

将{native-api-path}替换为实际的Google Analytics API端点路径。网关会将请求代理到analyticsadmin.googleapis.com和analyticsdata.googleapis.com,并自动注入您的OAuth令牌。

认证

所有请求都需要在Authorization头中包含Maton API密钥:

Authorization: Bearer $MATONAPIKEY

环境变量: 将您的API密钥设置为MATONAPIKEY:

bash
export MATONAPIKEY=YOURAPIKEY

获取您的API密钥

  1. 1. 在maton.ai登录或创建账户
  2. 前往maton.ai/settings
  3. 复制您的API密钥

连接管理

在https://ctrl.maton.ai管理您的Google OAuth连接。

重要: 管理API和数据API使用独立的连接:

  • - google-analytics-admin - 管理API端点必需(管理账户、媒体资源、数据流)
  • google-analytics-data - 数据API端点必需(运行报告)

根据您要使用的API创建所需的连接。

列出连接

bash

列出管理API连接


python < import urllib.request, os, json
req = urllib.request.Request(https://ctrl.maton.ai/connections?app=google-analytics-admin&status=ACTIVE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

列出数据API连接

python <header(Authorization, fBearer {os.environ[MATONAPI_KEY]}) print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF

创建连接

bash

创建管理API连接(用于管理账户、媒体资源、数据流)


python < import urllib.request, os, json
data = json.dumps({app: google-analytics-admin}).encode()
req = urllib.request.Request(https://ctrl.maton.ai/connections, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

创建数据API连接(用于运行报告)

python <header(Authorization, fBearer {os.environ[MATONAPI_KEY]}) req.add_header(Content-Type, application/json) print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF

获取连接

bash
python < import urllib.request, os, json
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id})
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

响应:
json
{
connection: {
connection_id: 21fd90f9-5935-43cd-b6c8-bde9d915ca80,
status: ACTIVE,
creation_time: 2025-12-08T07:20:53.488460Z,
lastupdatedtime: 2026-01-31T20:03:32.593153Z,
url: https://connect.maton.ai/?session_token=...,
app: google-analytics-admin,
metadata: {}
}
}

在浏览器中打开返回的url以完成OAuth授权。

删除连接

bash
python < import urllib.request, os, json
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id}, method=DELETE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

指定连接

如果您有多个Google Analytics连接,使用Maton-Connection头指定要使用的连接:

bash
python < import urllib.request, os, json
req = urllib.request.Request(https://gateway.maton.ai/google-analytics-admin/v1beta/accountSummaries)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Maton-Connection, 21fd90f9-5935-43cd-b6c8-bde9d915ca80)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

如果省略,网关将使用默认(最旧)的活动连接。

管理API参考

账户

bash
GET /google-analytics-admin/v1beta/accounts
GET /google-analytics-admin/v1beta/accounts/{accountId}
GET /google-analytics-admin/v1beta/accountSummaries

媒体资源

bash
GET /google-analytics-admin/v1beta/properties?filter=parent:accounts/{accountId}
GET /google-analytics-admin/v1beta/properties/{propertyId}

创建媒体资源

bash
POST /google-analytics-admin/v1beta/properties
Content-Type: application/json

{
parent: accounts/{accountId},
displayName: 我的新媒体资源,
timeZone: America/Los_Angeles,
currencyCode: USD
}

数据流

bash
GET /google-analytics-admin/v1beta/properties/{propertyId}/dataStreams

创建Web数据流

bash
POST /google-analytics-admin/v1beta/properties/{propertyId}/dataStreams
Content-Type: application/json

{
type: WEBDATASTREAM,
displayName: 我的网站,
webStreamData: {defaultUri: https://example.com}
}

自定义维度

bash
GET /google-analytics-admin/v1beta/properties/{propertyId}/customDimensions

创建自定义维度

bash
POST /google-analytics-admin/v1beta/properties/{propertyId}/customDimensions
Content-Type: application/json

{
parameterName: user_type,
displayName: 用户类型,
scope: USER
}

转化事件

bash
GET /google-analytics-admin/v1beta/properties/{propertyId}/conversionEvents
POST /google-analytics-admin/v1beta/properties/{propertyId}/conversionEvents

数据API参考

运行报告

bash
POST /google-analytics-data/v1beta/properties/{propertyId}:runReport
Content-Type: application/json

{
dateRanges: [{startDate: 30daysAgo, endDate: today}],
dimensions: [{name: city}

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 google-analytics-1776371350 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 google-analytics-1776371350 技能

通过命令行安装

skillhub install google-analytics-1776371350

下载

⬇ 下载 google-analytics v1.0.10(免费)

文件大小: 4.98 KB | 发布时间: 2026-4-17 14:07

v1.0.10 最新 2026-4-17 14:07
- Added clawdbot metadata with required environment variable (MATON_API_KEY) and emoji.
- No code or functional changes.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部