承接 kingfisherdirect/magento2-posthog 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

kingfisherdirect/magento2-posthog

Composer 安装命令:

composer require kingfisherdirect/magento2-posthog

包简介

PostHog Analytics integration module for Magento 2

README 文档

README

PostHog Analytics integration module for Magento 2.

Features

  • Global PostHog analytics integration
  • Admin panel configuration
  • CSP (Content Security Policy) whitelist included
  • Store-level configuration support
  • Easy to configure for multiple sites

Configuration

Navigate to: Stores > Configuration > General > PostHog

Settings

  • Enable PostHog: Yes/No

  • PostHog Project API Key: Your PostHog project API key (e.g., phc_...)

  • API Host: PostHog API host URL (default: https://eu.i.posthog.com)

  • Person Profiles: When to create person profiles:

    • Always
    • Identified Only (default)
    • Never

Installation

# Enable module
bin/magento module:enable KingfisherDirect_Posthog

# Run setup upgrade
bin/magento setup:upgrade

# Flush cache
bin/magento cache:flush

CLI Configuration

You can configure PostHog via CLI:

# Enable PostHog
bin/magento config:set posthog/general/enabled 1

# Set API Key
bin/magento config:set posthog/general/project_api_key "phc_YOUR_KEY_HERE"

# Set API Host
bin/magento config:set posthog/general/api_host "https://eu.i.posthog.com"

# Set Person Profiles
bin/magento config:set posthog/general/person_profiles "identified_only"

# Flush cache
bin/magento cache:flush

Multi-site Setup

For different sites, you can configure different PostHog projects:

# For a specific website
bin/magento config:set --scope=websites --scope-code=site1 posthog/general/project_api_key "phc_SITE1_KEY"
bin/magento config:set --scope=websites --scope-code=site2 posthog/general/project_api_key "phc_SITE2_KEY"

How It Works

The module adds the PostHog tracking script to all frontend pages via the default.xml layout. The script is injected into the after.body.start container for optimal performance.

File Structure

KingfisherDirect/Posthog/
├── Block/
│   └── Script.php                # Block class for rendering
├── Helper/
│   └── Data.php                  # Helper for configuration
├── Model/
│   └── Config/
│       └── Source/
│           └── PersonProfiles.php # Source model for dropdown
├── etc/
│   ├── acl.xml                   # ACL configuration
│   ├── adminhtml/
│   │   └── system.xml            # Admin system configuration
│   ├── config.xml                # Default configuration values
│   ├── csp_whitelist.xml         # CSP whitelist
│   └── module.xml                # Module declaration
├── view/
│   └── frontend/
│       ├── layout/
│       │   └── default.xml       # Global layout
│       └── templates/
│           └── script.phtml      # PostHog script template
└── registration.php              # Module registration

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-12-12