dreistromland / typo3-plausibleio
TYPO3 CMS的隐私友好型分析集成。使用Plausible Analytics分析您的受众,并在TYPO3后台直接查看美观的仪表板。
Requires
- php: ^8.1 | ^8.2 | ^8.3
- ext-json: *
- psr/http-client: *
- psr/http-factory: *
- psr/http-message: *
- psr/log: *
- typo3/cms-backend: ^12.4@dev | ^13.0@dev
- typo3/cms-core: ^12.4@dev | ^13.0@dev
- typo3/cms-dashboard: ^12.4@dev | ^13.0@dev
- typo3/cms-fluid: ^12.4@dev | ^13.0@dev
- typo3/cms-frontend: ^12.4@dev | ^13.0@dev
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- overtrue/phplint: ^9.1
- phpspec/prophecy-phpunit: ^2.0
- phpstan/extension-installer: ^1.0
- phpunit/phpunit: ^10.5
- roave/security-advisories: dev-latest
- saschaegerer/phpstan-typo3: ^1.8
- typo3/cms-extensionmanager: @dev
- typo3/cms-fluid-styled-content: ^12.4@dev || ^13.0@dev
- typo3/cms-install: @dev
- typo3/coding-standards: ^0.7 | ^0.8.x-dev
- typo3/testing-framework: ^8
- vimeo/psalm: ^5.0
This package is auto-updated.
Last update: 2024-08-28 11:53:42 UTC
README
使用Plausible Analytics为TYPO3 CMS提供隐私友好型分析集成。
使用Plausible Analytics分析您的受众,并在TYPO3后台直接查看美观的仪表板。
Plausible Analytics是一个隐私友好、无Cookie、轻量级和开源的分析替代方案 - 您可以在https://#上使用他们的服务,或者在您自己的平台上自托管服务。
安装
使用Composer
composer require dreistromland/typo3-plausibleio
不使用Composer
- 从TER下载扩展
- 使用扩展管理器安装
配置
站点语言
扩展主要在站点语言中配置,在站点管理
/ 站点
/ <站点配置>
/ 语言
/ <站点语言>
/ Plausible Analytics
下。
以下设置可用
Plausible API基本URL
Plausible API端点可访问的基本URL。
如果您使用plausible.io服务,则为https://#/
。
如果您使用自托管的Plausible实例,请在此处添加您的Plausible域名(例如https://analytics.example.com/
)。
Plausible API密钥
一个Plausible API令牌。如果您还没有,您可以在您的Plausible实例中的设置
/ API密钥
创建一个。
站点
一个Plausible站点ID。
这通常是您的域名或子域名,不带www
(例如waldhacker.dev
或blog.waldhacker.dev
)。
站点ID也是您在创建新站点时在Plausible实例中输入的(使用+ 添加网站
按钮)。
自动包含Plausible跟踪代码片段
如果开启,则Plausible跟踪脚本将自动包含在前端。
如果您不希望自动集成,您也可以使用资产收集器手动在模板中插入脚本,如下所示
<f:asset.script identifier="analytics" src="https://#/js/plausible.js" data="{'domain':'waldhacker.dev'}" priority="1" async="async" defer="defer" />
Plausible跟踪代码片段基本URL
Plausible跟踪脚本可访问的基本URL。
它必须是js/plausible.js
之前的部分。所以如果您的Plausible跟踪脚本在https://analytics.example.com/js/plausible.js
,则在此处放入https://analytics.example.com/
。
如果您使用plausible.io服务,则为https://#/
。
此URL很可能与“Plausible API基本URL”相同。但是,也可能发生跟踪脚本需要从另一个域加载的情况因为广告拦截器。因此,必须在此处单独配置Plausible跟踪脚本的基本URL。
Plausible跟踪代码片段类型
Plausible为不同的用例提供了不同的跟踪脚本。
可以在此处选择其中一个脚本(默认为plausible.js
)。
扩展配置
一些选项在扩展配置中配置,在管理工具
/ 扩展配置
/ plausibleio
下。
时间范围
仪表板小部件中可选的时间范围列表,以逗号分隔 - 请参阅https://#/docs/stats-api#time-periods以获取可能的选项(目前“custom”不可用)。
默认时间范围
在渲染小部件时最初使用的时间范围。
高级配置
Service.yaml
如果您想在单个仪表板上看到多个具有预配置值的仪表板,可以通过文件Configuration/Services.yaml
中的仪表板配置来实现。
因此,可以在仪表板上创建例如Countries
小部件2次。一个显示site1.example.com
的国家地图,另一个显示site2.example.com
的国家地图。
将waldhacker.plausibleio.widget.country
小部件从文件EXT:plausibleio/Configuration/Services.yaml
复制
waldhacker.plausibleio.widget.country:
class: 'Waldhacker\Plausibleio\Dashboard\Widget\CountryMapDataWidget'
arguments:
$configurationService: '@Waldhacker\Plausibleio\Services\ConfigurationService'
$options:
siteId: null
timeFrame: null
tags:
- name: dashboard.widget
identifier: 'plausible.countrymapdata'
groupNames: 'plausibleio'
title: 'LLL:EXT:plausibleio/Resources/Private/Language/locallang.xlf:widget.countryMapData.label'
description: 'LLL:EXT:plausibleio/Resources/Private/Language/locallang.xlf:widget.countryMapData.description'
iconIdentifier: 'content-widget-chart-bar'
height: 'medium'
width: 'medium'
到您的站点包Configuration/Services.yaml
文件中,并按如下方式调整配置
# Countries widget fixed to site1.example.com
yourname.plausibleio.widget.country.site1:
class: 'Waldhacker\Plausibleio\Dashboard\Widget\CountryMapDataWidget'
arguments:
$configurationService: '@Waldhacker\Plausibleio\Services\ConfigurationService'
$options:
siteId: site1.example.com
timeFrame: 30d
tags:
- name: dashboard.widget
identifier: 'yourname.countrymapdata.site1'
groupNames: 'plausibleio'
title: 'LLL:EXT:yourpackage/Resources/Private/Language/locallang.xlf:widgets.countryMapData.label'
description: 'LLL:EXT:yourpackage/Resources/Private/Language/locallang.xlf:widgets.countryMapData.description'
iconIdentifier: 'content-widget-chart-bar'
height: 'medium'
width: 'medium'
# Countries widget fixed to site2.example.com
yourname.plausibleio.widget.country.site2:
class: 'Waldhacker\Plausibleio\Dashboard\Widget\CountryMapDataWidget'
arguments:
$configurationService: '@Waldhacker\Plausibleio\Services\ConfigurationService'
$options:
siteId: site2.example.com
timeFrame: 30d
tags:
- name: dashboard.widget
identifier: 'yourname.countrymapdata.site2'
groupNames: 'plausibleio'
title: 'LLL:EXT:yourpackage/Resources/Private/Language/locallang.xlf:widgets.countryMapData.label'
description: 'LLL:EXT:yourpackage/Resources/Private/Language/locallang.xlf:widgets.countryMapData.description'
iconIdentifier: 'content-widget-chart-bar'
height: 'medium'
width: 'medium'
在$options
中,您可以将小部件固定到plausible站点ID和/或时间范围。
从1.x版本迁移到2.x版本
在1.x版本中,“Plausible API基本URL”选项(baseUrl
)、“Plausible API密钥”选项(apiKey
)和“站点”选项(siteId
)在扩展配置($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['plausibleio']
)中设置。然而,这只能在TYPO3安装中配置一个Plausible站点ID。
这三个配置选项已随着2.x版本移动到站点语言配置中。您必须手动将您在扩展配置(1.x版本)中输入的值转移到站点语言配置中,没有自动迁移脚本。
从2.x版本迁移到3.x版本
由于Breaking-96812-NoFrontendTypoScriptBasedTemplateOverridesInTheBackend,您需要从文件Configuration/Services.yaml
中小部件配置中删除$view: '@dashboard.views.widget'
行。
从waldhacker/typo3-plausibleio
3.x迁移到dreistromland/typo3-plausibleio
3.x
dreistrom.land AG已接管扩展的维护。在这种情况下,包命名空间已从waldhacker/typo3-plausibleio
更改为dreistromland/typo3-plausibleio
。要将您的项目迁移到新命名空间,请执行类似以下操作
composer rem waldhacker/typo3-plausibleio && composer req dreistromland/typo3-plausibleio:^3.0