英文:
GTM Data Layer Variable Version 1 is not working
问题
我在我的GTM容器中创建了3个数据层变量。
-
firstName - 版本2
-
lastName - 版本2
-
phoneNumber - 版本1
dataLayer.push
后数据层的预期输出
-
在第一个事件中,有人分享了电话号码
{firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}
-
在第二个事件中,他删除了他的电话号码
{firstName: 'John', lastName: 'Cena'}
dataLayer.push
后当前数据层的输出
-
在第一个事件中,有人分享了电话号码
{firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}
-
在第二个事件中,他删除了他的电话号码
{firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}
版本1仍然像版本2一样工作。
是否可以组合使用版本1和版本2,还是所有变量都应该具有相同的版本?
英文:
I have created 3 data layer variables in my GTM container.
-
firstName - version 2
-
lastName - version 2
-
phoneNumber - version 1
Expected output of Data layer after dataLayer.push
-
In first event some one shares phone number
{firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}
-
In second event he removes his phone number
{firstName: 'John', lastName: 'Cena'}
Current output of data layer after dataLayer.push
-
In first event some one shares phone number
{firstName: 'John', lastName: 'Cena', phoneNumber: '999-999-999-9'}
-
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论