【问题标题】:Tealium Tagging (Google Analytics)Tealium 标记(谷歌分析)
【发布时间】:2020-06-05 17:48:19
【问题描述】:

我刚开始使用 Tealium。我正在尝试将 Tealium Tag 合并到上次登录信息中。我该怎么做?下面是代码:

上次登录日期的 HTML 组件

S-component.html

<div #greeting class="greeting-message">
        <ng-container *ngIf="userProfile$ | async as userProfile">
          <h1 qa-name="greetingMessage">
            Good {{ timeOfDay }},
            {{ userProfile.displayName || userProfile.firstName || '' }}
          </h1>
          <p *ngIf="userProfile.lastLoginDate" qa-name="lastLoggedIn">
            You last logged in at
            {{
              userProfile.lastLoginDate | date: "h:mm:ssaaaaa'm' on MMMM d, y"
            }}
          </p>
          <p *ngIf="!userProfile.lastLoginDate">
            Welcome!
          </p>
        </ng-container>
      </div>

下面是用户资料界面

i-user-profile.ts

export interface IUserProfile {
  lastLoginDate?: Date
}

下面是包含用户登录时间和时间的打字稿组件

S-component.ts

import {
  IUserProfile
} from '@shared/interfaces';
import {
  TealiumService
} from '@shared/services';

export class SComponent implements OnInit {
  private static getTimeOfDay(hour: number): TimeOfDay;

 public ngOnInit() {
    this.timeOfDay = AccountSummaryComponent.getTimeOfDay(
      new Date().getHours()
    );
  }

 constructor(
   private readonly _tealiumService: TealiumService,
   private readonly _userService: UserService
 ) {
   this.userProfile$ = this._userService.profileChanges();
   this.timeOfDay = SComponent.getTimeOfDay(
    new Date().getHours()
  );
 }
}

【问题讨论】:

    标签: html angular typescript tealium


    【解决方案1】:

    如果您想将该数据传递到 Tealium,那么您有几个不同的选择。您需要确保您的页面已经包含 Tealium 标签,有关如何添加该标签的详细信息,请参阅Tealium's docs。如果您使用服务器端产品,那么您可以创建一个访问者属性来保存上次登录日期,这可以在仪表板中完成,而无需修改您的代码。

    如果您只使用客户端产品,则需要将userProfile.lastLoginDate 变量添加到页面上的 utag_data 对象。当调用utag.view() 时,此数据将被传递到 Tealium。您需要添加的代码的相关部分位于加载 utag.js 文件之前的脚本中。在上一个链接中有更多关于此的信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-14
      • 1970-01-01
      • 1970-01-01
      • 2012-11-20
      相关资源
      最近更新 更多