trialfireinc/tracker 问题修复 & 功能扩展

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

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

trialfireinc/tracker

Composer 安装命令:

composer require trialfireinc/tracker

包简介

Trialfire tracking module for Magento 2

README 文档

README

This module adds support for Trialfire to Magento 2. In addition to normal behavioural tracking, the following events are also collected:

  • Viewed Category
  • Viewed Product
  • Add to Cart
  • Add to Whishlist
  • Remove from Cart
  • Started Checkout
  • Completed Order
  • Subscribed Newsletter
  • Register an Account

Install

Install from Magento Marketplace

https://marketplace.magento.com/trialfireinc-tracker.html

Install from Command Line

  1. Require the trialfireinc/tracker package. A list of version tags is available here.
php composer.phar require trialfireinc/tracker:v1.1.4
  1. Enable the module.
bin/magento module:enable Trialfire_Tracker --clear-static-content
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy
bin/magento cache:clean

Configure

The only required configuration is the API key from your project in Trialfire. You can find the API key by logging in to your Trialfire account and navigating to Settings > Tracking Code and API key.

  1. Open the Admin page for your store and navigate to Stores > Configuration, then click on the Trialfire tab.

  2. Set the Enable Tracking field to Yes, and then input your API key into the API token field.

  3. Save the configuration.

  4. Flush the Configuration, Block HTML, and Full_Page caches. You can clear the caches from System > Cache Management or use the command bin/magento cache:flush config block_html full_page.

Advanced Configuration

Complete documentation is available here.

Custom Initialization

Customize how Trialfire tracking code is included into the DOM. The default implementation is similar to the following:

var s = document.createElement('script');
s.src = this.assetUrl;
document.head.appendChild(s);
Trialfire.init(this.apiToken);

The value of this for the custom initializer is the following.

{
  // The value of the Asset URL setting in your store's Trialfire configuration.
  assetUrl: '...',

  // The value of the API Token setting in your store's Trialfire configuration.
  apiToken: '...',                  

  /**
   * Call the default initialization logic.
   */
  callDefaultInit: function () ...  

  /**
   * Inject the Trialfire script into the DOM but do not call Trialfire.init().
   */
  injectScript: function () ...
}

To prevent Trialfire from loading on the 'agent' subdomain, input the following JavaScript into the Initialization Code textarea.

// If host does not start with 'agent'.
if (!location.host.startsWith('agent.myshop.com')) {
  // Invoke the default initialization logic.
  this.callDefaulInit();
}

Custom Event Handlers

Customize how Trialfire fires tracking events. The value of this for the custom event handler is the following.

this.event: An object containing information about the event. The contents vary with the event type but are similar to the following.

this.event = {
  $name: 'placeOrder',
  apiToken: '...',
  userId: 1,
  traits: {
    email: '...',
    firstName: '...'
  },
  props: {
    orderId: '...',
    products: [{
      id: '...',
      name: '...',
      sku: '...'
    },{
      ...
    }]
  }
}

this.tfMage: The service which tracks the events. It contains utility methods that you may use in your custom handler.

this.tfMage = {
  /**
   * Calls the default handler for an event.
   */
  callDefaultEventHandler: function (event) ...
};

Example:

To prevent Trialfire from tracking orders on the 'agent' subdomain, input the following JavaScript into the Place Order textarea.

// If host does not start with 'agent'.
if (!location.host.startsWith('agent.myshop.com')) {
  // Invoke the default handler for this event.
  this.tfMage.callDefaultEventHandler(this.event);
}

trialfireinc/tracker 适用场景与选型建议

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

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

围绕 trialfireinc/tracker 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2021-04-22