GTM Data Layer Variable Version 1 is not working.

huangapple go评论55阅读模式
英文:

GTM Data Layer Variable Version 1 is not working

问题

我在我的GTM容器中创建了3个数据层变量。

  1. firstName - 版本2

  2. lastName - 版本2

  3. phoneNumber - 版本1

dataLayer.push 后数据层的预期输出

  1. 在第一个事件中,有人分享了电话号码
    {firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}

  2. 在第二个事件中,他删除了他的电话号码
    {firstName: 'John', lastName: 'Cena'}

dataLayer.push 后当前数据层的输出

  1. 在第一个事件中,有人分享了电话号码
    {firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}

  2. 在第二个事件中,他删除了他的电话号码
    {firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}

版本1仍然像版本2一样工作。

是否可以组合使用版本1和版本2,还是所有变量都应该具有相同的版本?

英文:

I have created 3 data layer variables in my GTM container.

  1. firstName - version 2

  2. lastName - version 2

  3. phoneNumber - version 1

Expected output of Data layer after dataLayer.push

  1. In first event some one shares phone number
    {firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}

  2. In second event he removes his phone number

    {firstName: 'John', lastName: 'Cena'}

Current output of data layer after dataLayer.push

  1. In first event some one shares phone number
    {firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}

  2. In second event he removes his phone number

    {firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}

Version 1 still works like Version 2

Is it even possible to use combination of Version 1 and 2 or all variables should have same version?

答案1

得分: 0

你当然可以根据需要同时使用 v1 和 v2 的组合。使用 v1 可能是处理相同对象被推送不同值的解决方案,这取决于你的推送对象结构。然而,v1 有其局限性。

有一篇非常好的文章详细介绍了 v1 和 v2 的区别以及使用情况,来自 Simo,点击此处查看。基本上,v1 仅支持推送数据的平面结构,不支持复杂对象的递归合并,这可能是因为它无法识别对象的复杂性而导致的结果。

然而,在你的示例中,你只是将简单的平面对象推送到数据层,所以你可能甚至察觉不到这些差异。

英文:

You can definitely use the combo of v1 and v2 as you see fit. And using v1 may be a solution to same object being pushed with different values. Depends on your pushed objects structure. V1 has its limitations however.

There's a very good article covering the difference and use cases for v1 and v2 here from Simo. Basically, v1 only supports flat structure of the pushed data and no recursive merging of complex objects. Probably as a logical result of not recognizing the complexity of objects.

In your example, however, you have simple flat objects pushed to the DL, so you may not even notice the difference.

huangapple
  • 本文由 发表于 2023年2月24日 06:05:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75550796.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定