ensue/ga4
Composer 安装命令:
composer require ensue/ga4
包简介
Reporting API for Google analytics V4
关键字:
README 文档
README
This package aims to provide methods for working with the Data API v1 of Google Analytics 4.
Getting Started
Installation
You can install the package using Composer. Run the following command:
composer require ensue/ga4
Prerequisites
| Package | Minimum Version |
|---|---|
| Laravel | 13 |
| php | 8.3 |
Configuration and Language Files (Optional)
php artisan vendor:publish --tag=ga4
Dependencies
Follow the step 1 and 2 provided in Google Analytics Data API (GA4) QuickStart. After downloading the service account credentials, store them in the storage directory of your Laravel project.
Environment Changes
Add the following parameters to your .env file:
GA4_PROPERTY_ID=<YOUR-PROPERTY-ID>
GA4_CREDENTIALS_JSON_PATH=<FILE-STORED-IN-STORAGE-DIR>
Reporting
To grant access to view the data, provide the "client email" access in your Google Analytics account's user management through your admin settings.
Provided methods
Run single report
GA::runReport($attributes);
Run Batch Report
You can run up to 5 reports simultaneously.
GA::runBatchReport($attributes);
Request Body
Run single report
Maximum Dimensions allowed: 9
Maximum Metrics allowed: 10
$attributes = [
"date_range" => [
"start_date" => "Y-m-d"
"end_date" => "Y-m-d"
],
"dimensions" => [],
"metrics" => [],
"dimension_filter" => [FILTER_OPTIONS],
"metric_filter" => [FILTER_OPTIONS],
"offset" => integer,
"limit" => integer,
"metric_aggregations": [],
"order_by": [],
"currency_code": string,
"return_property_quota": boolean
];
Run Batch Report
$attributes = [
[
"title" => string,
<key value pair of single report>
],
[
"title" => string,
<key value pair of single report>
],
]
Filter options
"filter" => [
"field_name" => "{DIMENSION_NAME}"
"expression" => "{FILTER_EXPRESSION}"
"expression_data" => []
],
"and_group" => [
[
"field_name" => "{DIMENSION_NAME}"
"expression" => "{FILTER_EXPRESSION}"
"expression_data" => []
]
],
"or_group" => [
[
"field_name" => "{DIMENSION_NAME}"
"expression" => "{FILTER_EXPRESSION}"
"expression_data" => []
]
],
"not_expression" => [
"field_name" => "{DIMENSION_NAME}"
"expression" => "{FILTER_EXPRESSION}"
"expression_data" => []
],
Expression options
String filter
"expression" => FilterExpression::STRING_FILTER,
"expression_data" => [
"match_type" => MatchType::options
"value" => "{VALUE}",
"case_sesitive" => boolean,
]
In list filter
"expression" => FilterExpression::IN_LIST_FILTER,
"expression_data" => [
"values" => [VALUES],
"case_sensitive" => boolean,
]
Numeric filter
"expression" => FilterExpression::NUMERIC_FILTER,
"expression_data" => [
"operation" => Operation::options,
"value" => [
"int64" => integer,
"double" => integer
]
]
Between Filter
"expression" => FilterExpression::BETWEEN_FILTER,
"expression_data" => [
"from" => [
"int64" => integer,
"double" => integer
],
"to" => [
"int64" => integer,
"double" => integer
]
]
Order by options
Order by dimension
"expression" => OrderBy::DIMENSION,
"expression_data" => [
"name" => Dimensions::NAME
]
Order by metric
"expression" => OrderBy::METRIC,
"expression_data" => [
"name" => Dimensions::NAME
]
Order by pivot
"expression" => OrderBy::PIVOT,
"expression_data" => [
"name" => Dimensions::NAME,
"pivotSelections" => [
[
"dimensionName" => string,
"dimensionValue" => string
]
]
]
Contributing
Feel free to contribute :)
ensue/ga4 适用场景与选型建议
ensue/ga4 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 385 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「analytics」 「Ensue」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ensue/ga4 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ensue/ga4 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ensue/ga4 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Analytics chooser extensions for site settings.
A Laravel Nova Card to show Fathom Analytics stats.
Modular architecture build on top of laravel for any laravel project
Laravel 5 package to retrieve Google Analytics data.
Scout Extended extends Laravel Scout adding algolia-specific features
PHP library for Bluelabs Erwin
统计信息
- 总下载量: 385
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-11-18