0

我是使用Tealium的新手。我正在尝试将Tealium 标签合并到上次登录信息中。我该怎么做?下面是代码:

上次登录日期的 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-组件.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()
  );
 }
}
4

1 回答 1

0

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

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

于 2020-06-06T15:46:33.977 回答