dreistromland/typo3-plausibleio

TYPO3 CMS的隐私友好型分析集成。使用Plausible Analytics分析您的受众,并在TYPO3后台直接查看美观的仪表板。

安装: 17

依赖项: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 2

公开问题: 3

类型:typo3-cms-extension

3.0.0 2024-05-28 10:01 UTC

This package is auto-updated.

Last update: 2024-08-28 11:53:42 UTC


README

CI

使用Plausible Analytics为TYPO3 CMS提供隐私友好型分析集成。

使用Plausible Analytics分析您的受众,并在TYPO3后台直接查看美观的仪表板。

Plausible Analytics是一个隐私友好、无Cookie、轻量级和开源的分析替代方案 - 您可以在https://#上使用他们的服务,或者在您自己的平台上自托管服务

Image of Dashboards

安装

使用Composer

composer require dreistromland/typo3-plausibleio

不使用Composer

配置

站点语言

扩展主要在站点语言中配置,在站点管理 / 站点 / <站点配置> / 语言 / <站点语言> / Plausible Analytics下。

Image of plausible configuration within site language settings

以下设置可用

Plausible API基本URL

Plausible API端点可访问的基本URL。
如果您使用plausible.io服务,则为https://#/
如果您使用自托管的Plausible实例,请在此处添加您的Plausible域名(例如https://analytics.example.com/)。

Plausible API密钥

一个Plausible API令牌。如果您还没有,您可以在您的Plausible实例中的设置 / API密钥创建一个。

Image of Plausible settings

站点

一个Plausible站点ID。
这通常是您的域名或子域名,不带www(例如waldhacker.devblog.waldhacker.dev)。
站点ID也是您在创建新站点时在Plausible实例中输入的(使用+ 添加网站按钮)。

Image of Plausible settings

自动包含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下。

Image of plausible configuration within the extension settings

时间范围

仪表板小部件中可选的时间范围列表,以逗号分隔 - 请参阅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