定制 bencarr/craft-fathom-analytics 二次开发

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

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

bencarr/craft-fathom-analytics

最新稳定版本:1.0.0-beta.2

Composer 安装命令:

composer require bencarr/craft-fathom-analytics

包简介

An unofficial Fathom Analytics integration for Craft CMS

README 文档

README

A Craft CMS plugin to surface your Fathom Analytics data in the Craft control panel.

Features

This plugin is intended to help content authors get a nice overview of site analytics, and surface some contextual information they can use to tailor their content changes. It’s a companion, not a replacement for your Fathom Analytics dashboard.

Dashboard Widgets

Fantastic dashboard widgets with customizable date ranges to keep an eye on what’s most important to you:

  • Current Visitors — How many people are on your site right now, where are they, and where were they referred from?
  • Browsers — Breakdown of your traffic by browser.
  • Device Type — Breakdown of your traffic by desktop, mobile, and tablet.
  • Top Pages — List of your top 10 pages by visits and views.
  • Top Referrers — List of your top 10 referrers by visits and views.
  • Visitors — Chart of visitors and pageviews over time.
  • Overview — Basic totals for number of visits, number of visitors, average time on site, and bounce rate.

Entry Sidebar Widget

A mini widget with entry-specific analytics right in the entry edit form with tabs to cover all the basics:

  • Overview — Visitors, views, average time on page, and bounce rate.
  • Visitors — Chart of visitors and pageviews over time.
  • Browsers — Breakdown of traffic by browser.
  • Devices — Breakdown of traffic by desktop, mobile, and tablet.
  • Referrers — List of the top 10 referrers by visits and views.

Requirements

This plugin requires Craft CMS 4.5.0 or later, and PHP 8.0.2 or later.

Installation

You can install this plugin from the Plugin Store or with Composer.

From the Plugin Store

Go to the Plugin Store in your project’s Control Panel and search for “Fathom Analytics”. Then press “Install”.

With Composer

Open your terminal and run the following commands:

# go to the project directory
cd /path/to/my-project.test

# tell Composer to load the plugin
composer require bencarr/craft-fathom-analytics

# tell Craft to install the plugin
./craft plugin/install fathom

Configuration

Once the plugin is installed, you’ll need to configure your API Key and Site ID either using the plugin settings page or a configuration file. You can generate an API key from your Fathom Analytics account, and find your site ID by clicking the site from your sites list.

From the Plugin Settings Page

On an environment with admin changes enabled, open Settings then press “Fathom Analytics” under the “Plugins” section. Your API key is sensitive data, so you’ll probably want to use an environment variable that you keep out of version control.

From a Configuration File

Create a file called fathom.php in your config/ directory.

<?php

use craft\helpers\App;

return [
    '*' => [
        'apiKey' => App::env('FATHOM_API_KEY'),
        'siteId' => App::env('FATHOM_SITE_ID'),
    ],
];

Extending

Modifying Available Date Ranges

The plugin comes with a set of default ranges covering a scale of time from 1 day to 1 year. You can modify these ranges using the EVENT_DEFINE_WIDGET_RANGES event.

Default Ranges

Range Key
Last 24 Hours today
Last 7 Days last_7_days
Last 14 Days last_14_days
Last 30 Days last_30_days
Last 60 Days last_60_days
Last 90 Days last_90_days
Last 180 Days last_180_days
Last 365 Days last_365_days

Removing a Default Range

Remove a default range by unsetting its key in the ranges array.

use bencarr\fathom\events\RegisterWidgetRangesEvent;
use bencarr\fathom\FathomPlugin;
use craft\base\Event;

Event::on(
    FathomPlugin::class, 
    FathomPlugin::EVENT_DEFINE_WIDGET_RANGES, 
    function (RegisterWidgetRangesEvent $event) {
        unset($event->ranges['last_365_days'])
    }
);

Adding a Custom Range

The ranges event expects a keyed array of WidgetDateRange objects. To add a new range, add a new key to the ranges array on the event and construct a WidgetDateRange instance with your desired configuration:

use bencarr\fathom\events\RegisterWidgetRangesEvent;
use bencarr\fathom\helpers\WidgetDateRange;
use bencarr\fathom\FathomPlugin;
use craft\base\Event;
use craft\helpers\DateTimeHelper;

Event::on(
    FathomPlugin::class, 
    FathomPlugin::EVENT_DEFINE_WIDGET_RANGES, 
    function (RegisterWidgetRangesEvent $event) {
        $event->ranges['last_2_years'] = new WidgetDateRange(
            label: 'Last 2 Years',
            start: DateTimeHelper::tomorrow()->sub(new DateInterval('P2Y')),
            end: DateTimeHelper::tomorrow(),
        );
    }
);

bencarr/craft-fathom-analytics 适用场景与选型建议

bencarr/craft-fathom-analytics 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 bencarr/craft-fathom-analytics 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bencarr/craft-fathom-analytics 我们能提供哪些服务?
定制开发 / 二次开发

基于 bencarr/craft-fathom-analytics 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: mit
  • 更新时间: 2024-01-25