rainlab/googleanalytics-plugin
Composer 安装命令:
composer require rainlab/googleanalytics-plugin
包简介
Google Analytics integration plugin for October CMS
README 文档
README
This plugin adds Google Analytics 4 tracking and reporting features to October CMS. This plugin requires October CMS 3.3 or above.
Note: This plugin does not support Universal Analytics.
Important: this plugin requires the
bcmathPHP extension. It is required by the Google PHP API.
If you are using October CMS v1 or v2, install v1.3 of the plugin with the following command:
composer require rainlab/googleanalytics-plugin "^1.3"
Configuring the Google Analytics and Google Cloud accounts
To use the plugin, you will need to have a Google Cloud project with a service account, as well as the Google Analytics Data API enabled for that project. To begin, sign into the Google Cloud Console and create or select your project.
To create a service account in a Google Cloud project:
- Open the Credentials page and select your project.
- Click the Create credentials button and select Service account.
- Enter a name for the service account, e.g. "October CMS GA". Enter an ID for the service account, e.g. "october-cms-ga".
- Click Done. This will create the service account and redirect back to the account list.
To generate and download a private key file for the service account:
- Click the account you just created in the Service Accounts list.
- Click Keys in the top menu.
- Click Add Key / Create new key and select JSON. This will download the JSON file. You will need this file later to configure the plugin.
The plugin requires Google Analytics Data API to be enabled for the Google Cloud project. This is needed to fetch the analytics data and display it on the October CMS dashboard. To enable the API:
- Return to the project dashboard page in the Google Cloud Console.
- Click Enabled APIs & services in the sidebar.
- Click Enable APIs and services in the top menu.
- Search for "Google Analytics Data API".
- Click the found API and enable it.
You can alternatively use this link, but make sure you're enabling the API for the correct project.
Next, you need to give the service account access to your Google Analytics account:
- In the Google Cloud dashboard select your project, click APIs & Services and then Credentials in the sidebar.
- In the Service Accounts list, copy email of the service account you created.
- Go to Google Analytics and select a GA4 property you want to work with.
- In the left-hand menu, click Admin.
- In the Property column, click on Property Access Management.
- Click the Add + button and enter the email address of the service account.
- Select the Viewer permission for the service account.
- Click the Add button to save the changes.
Configuring the plugin
- Open your October CMS installation Administration Area and go to Settings / Google Analytics.
- Upload the JSON file you downloaded before to the Private key field.
- To find the Analytics Property ID - go to your Google Analytics property's Admin page and click Property Settings. Copy the Property ID value from the page and paste it into the corresponding field on the plugin settings page.
- To find the Measurement ID value you first need to create a Data Stream on the Admin page of your Google Analytics 4 property. After creating a stream, click it in the stream list and copy the Measurement ID value. Paste it into the corresponding field on the plugin settings page.
- Save the settings.
Installing the Google Analytics tracking code
You can use Google Tag Manager to install the tracker code. Below is an explanation how to install the tracker code manually.
- Drop the Google Analytics Tracker component to your CMS layout.
- Add the following code to the layout immediately after the element:
{% component 'googleTracker' %}
After installing the tracker, you can add Google Analytics dashboard widgets and preview the traffic statistics without leaving October CMS.
Compatibility with Multisite
If every site should have its own analytics settings and widgets, open the config/multisite.php file and enable the setting below. Change the value to true to enable unique configuration for each site definition.
'features' => [ // ... 'rainlab_googleanalytics_setting' => false, ]
Troubleshooting
Fix for Windows / XAMPP
cURL error 60: SSL certificate problem: unable to get local issuer certificate
-
Follow this link: http://curl.haxx.se/ca/cacert.pem and save it in a file called
cacert.pem. -
Open your
php.inifile insert or edit the following line:curl.cainfo = "[pathtothisfile]\cacert.pem" -
Restart Apache
Popup message simply saying "error" when trying to add the JSON key file.
Some ad-blockers, such as Chrome's uBlock Origin extension or Firefox's own built-in algorithms, may prevent the uploading of the JSON file key. Disabling these, or whitelisting the October CMS website, may resolve this issue for you.
License
This plugin is an official extension of the October CMS platform and is free to use if you have a platform license. See EULA license for more details.
rainlab/googleanalytics-plugin 适用场景与选型建议
rainlab/googleanalytics-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 975 次下载、GitHub Stars 达 21, 最近一次更新时间为 2021 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cms」 「analytics」 「google」 「october」 「rainlab」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rainlab/googleanalytics-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rainlab/googleanalytics-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rainlab/googleanalytics-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Analytics chooser extensions for site settings.
A Laravel Nova Card to show Fathom Analytics stats.
Integrate with Snipcart.
统计信息
- 总下载量: 975
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2021-03-26