axllent/silverstripe-analytics-js 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

axllent/silverstripe-analytics-js

最新稳定版本:5.0.0

Composer 安装命令:

composer require axllent/silverstripe-analytics-js

包简介

Google Universal Analytics tracking code for Silverstripe

README 文档

README

Please note that the functionality provided by this module is now fairly redundant since the release of Google Analytics 4 (GA4), and is no longer in active development.

If you're looking for an alternative then take a look at springtimesoft/silverstripe-tracking-scripts.

An extension to add Google Universal Analytics gtag() tracking code (not to be confused with Google Tag Manager) to your Silverstripe templates.

It automatically includes optional unobtrusive event tracking for all outbound links & "asset downloads", as well as event tracking for 404 and error pages, email & telephone links.

Features

  • Google Universal Analytics (gtag.js) code injected automatically into <head> of page to prevent JavaScript conflicts due to loading order (if you are using custom gtag() functions in your other code.
  • Automatic pageview tracking for all configured accounts, including tracking of 404 & 500 page errors (tracked as "Page Not Found" / "Page Error" events).
  • Unobtrusive outbound, download, email & tel: link tracking - monitors all page clicks, rather than on page load (ie: works with links including those generated by Ajax etc on the page after page load).
  • Uses Google Analytics hitCallback for tracking for outgoing links to register before load (ie: when no link target is set) to ensure tracker is successfully run before redirection.
  • Tracking codes are automatically changed to G-XXXXXXXX-[1-9] if SS_ENVIRONMENT_TYPE is not live, or if page URL matches ?flush= to prevent bad data capture.

Event tracking

Additional event tracking is automatically enabled by default for:

  • File downloads (all non-image files in the assets folder) are tracked as "Downloads".
  • Outgoing links are tracked as "Outgoing Links".
  • Email (mailto:) links are tracked as "Email Links".
  • Phone (tel:) links are tracked as "Phone Links".

Event category names (eg: "Outgoing Links", "Downloads" etc) can be configured in your yaml config.

Note: Event tracking only works with regular (left-or-middle) mouse button clicks (including combinations with Ctrl/Shift/Meta keys). Tracking is bypassed if the user right-clicks on a link and selects an action from the context menu (open in new tab, save as etc...). Unfortunately there is no way around this without disabling the content menu entirely.

Requirements

  • Silverstripe ^6

For Silverstripe 4 & 5, please refer to the Silverstripe5 branch.

For the deprecated analytics.js tracking method for Silverstripe 4, please refer to the analytics.js branch.

For Silverstripe 3, please refer to the Silverstripe3 branch.

Installation via Composer

You can install it via composer with

composer require axllent/silverstripe-analytics-js

Basic usage

Once installed the extension is automatically loaded if you provide at least one tracking account in your config yaml file (eg) app/_config/analytics.yml

Axllent\AnalyticsJS\AnalyticsJS:
  tracker:
    - ['config', 'G-XXXXXXXX']

The syntax is very similar to the official documentation, so things like secondary trackers or other configurations can be easily added.

Axllent\AnalyticsJS\AnalyticsJS:
  tracker:
    - ['config', 'G-XXXXXXXX']          # default account [required]
    - ['config', 'G-XXXXXXXX-1']          # add secondary tracker
    - ['set', 'forceSSL', true]           # force tracking to use SSL
    - ['require', 'ecommerce', 'ecommerce.js']  # load ecommerce extension
  track_links: false                      # disable external link & asset tracking
  ignore_link_class:  "notrack"           # if "track_links", then ignore external links with the "notrack" class
  compress_js: false                      # do not compress inline JavaScript
  primary_gtag_id: "G-XXXXXXXX"         # set the default tracking id to be used when loading gtag (defaults to the first tracker)

Please refer to the Configuration.md for all configuration options.

To start live tracking, make sure your website is in live mode, or if running in dev or staging that you have the track_in_dev_mode: true option.

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固