定制 aimeos/laravel-analytics-cloudflare 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aimeos/laravel-analytics-cloudflare

Composer 安装命令:

composer require aimeos/laravel-analytics-cloudflare

包简介

Cloudflare driver for Laravel Analytics Bridge

README 文档

README

Cloudflare driver for Laravel Analytics bridge.

Cloudflare Web Analytics requires two credentials to query data via the Analytics API:

  • siteTag → A unique identifier for your website.
  • API Token → An access token that authorizes your app to query the GraphQL API.

1. Find Your siteTag

The siteTag is generated when you enable Web Analytics for a domain.

  1. Log in to Cloudflare Dashboard.
  2. Select your website from the list.
  3. In the sidebar, go to Analytics → Web Analytics.
  4. If you haven’t yet enabled Web Analytics, click Enable Web Analytics and follow the setup.
  5. Cloudflare will show you a JavaScript snippet to embed in your site. Example:
    <script defer src="https://static.cloudflareinsights.com/beacon.min.js"
            data-cf-beacon='{"token": "abcd1234efgh5678ijkl9012mnop3456", "siteTag": "xyz987654321"}'></script>
  6. Copy the siteTag value from inside the data-cf-beacon attribute.

Note: The siteTag is unique per domain you configure.

2. Create an API Token

You need a token to access the Cloudflare GraphQL Analytics API.

  1. Go to your Cloudflare Dashboard → My Profile → API Tokens.
  2. Click Create Token.
  3. Choose Create Custom Token.
  4. Add permissions:
    • Account → Analytics → Read
    • (If you only want Web Analytics, this scope is enough.)
  5. Select the account that contains your website.
  6. Save and copy the generated API Token.

3. Configure in Analytics Bridge

The ./config/analytics-bridge.php file already contains:

return [
    'default' => env('ANALYTICS_DRIVER'),

    'drivers' => [
        'cloudflare' => [
            'siteTag' => env('CLOUDFLARE_SITETAG'),
            'token' => env('CLOUDFLARE_TOKEN'),
        ],
        /* ... */
    ],
    /* ... */
];

Add the required key/value pairs to your .env file:

ANALYTICS_DRIVER="cloudflare"
CLOUDFLARE_SITETAG="..."
CLOUDFLARE_TOKEN="..."

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-2.1
  • 更新时间: 2025-09-12