定制 sstottelaar/pirsch-statamic-addon 二次开发

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

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

sstottelaar/pirsch-statamic-addon

Composer 安装命令:

composer require sstottelaar/pirsch-statamic-addon

包简介

README 文档

README

Seamlessly integrate Pirsch Analytics into your Statamic site with a focus on privacy and server-side tracking.

Features

  • Server-Side Tracking: integrates Pirsch easily without client-side Javascript for basic pageview tracking. This enhances user privacy and prevents adblockers from interfering
  • Automatic Filtering: automatically excludes visits from your local development environment (configurable)
  • Antlers Tags: provides simple Antlers tags for easy custom event tracking directly from your templates
  • Dashboard Link: easy access to the Pirsch dashboard directly from the CP

Requirements

  • Statamic v5 / v6
  • PHP 8.2+
  • A Pirsch account

Installation

  1. Install the addon using Composer:

    composer require sstottelaar/pirsch-statamic-addon
  2. (Optional) Publish the configuration file if you need to customize default settings (like excluded domains):

    php please vendor:publish --tag="pirsch-config"

    This creates a config/pirsch.php file. Using .env variables is generally preferred for credentials.

Configuration

  1. Get your Pirsch Access Key:

    • Log in to your Pirsch dashboard.
    • Go to Settings -> Integration.
    • Ensure the correct domain/website is selected (top right).
    • Scroll down to the "Clients" section and click Add Client.
    • Select the Access Key (write-only) type.
    • Give the client a descriptive name (e.g., "Statamic Production Site").
    • Copy the generated Client Secret (this is your token).
  2. Add the Token to your Environment: Open your .env file and add the copied token:

    PIRSCH_TOKEN=pa_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    • Important: Make sure to add this variable to your production .env file as well.
    • Tip: Leave the PIRSCH_TOKEN variable empty or unset in non-production environments (like local or staging) to automatically disable tracking there.

How it Works

Once installed and configured with a valid PIRSCH_TOKEN, the addon automatically starts tracking pageviews on every request using Pirsch's server-side tracking capabilities. No further setup is needed for basic tracking.

This addon handles pageviews server-side, eliminating the need for the Pirsch JavaScript snippet for core tracking. Manually add the snippet only if you specifically require client-side event tracking via JavaScript.

Usage

Basic Pageview Tracking

Automatic, no action required after configuration.

Event Tracking (Antlers)

Use the provided Antlers tag in your templates to track custom events:

{{ pirsch:event name="Contact form submitted" }}

Example with meta data:

{{ pirsch:event name="Contact form submitted" \metadata='{"form": "contact"}' }}

Never send Personally Identifiable Information (PII) or any sensitive user-specific data in the event metadata. You are responsible for ensuring compliance with privacy regulations (like GDPR). Use the metadata feature cautiously and at your own risk. For best practices, consult the Pirsch Event Documentation.

Dashboard link

Pirsch has the ability to create access links. To create an access link:

  1. Log in to your Pirsch dashboard.
  2. Go to Settings -> Access.
  3. Scroll down to the Access Links section
  4. Add a new access link and copy the link
  5. Open your .env file and the follow:
    PIRSCH_DASHBOARD_URL="https://xxxxx.pirsch.io/?access=xxxxxxxxxxxxxxxxxxxx"

Roadmap

  • Enhance event tracking capabilities (e.g., duration)
  • Add a convenient link in the CP to navigate to your Pirsch Dashboard
  • Display Pirsch statistics directly in the Statamic Control Panel

Issues

If you experience any issues, please make a GitHub issue or contact me at sjoerdstottelaar.nl

Contributing

Contributions are welcome! Please create an issue or submit a pull request.

License

This project is licensed under the MIT License.

sstottelaar/pirsch-statamic-addon 适用场景与选型建议

sstottelaar/pirsch-statamic-addon 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 111 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 sstottelaar/pirsch-statamic-addon 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-17