如何在Google跟踪代码管理器中测试数据层变量? [英] How to test data layer variables in Google Tag Manager?

查看:71
本文介绍了如何在Google跟踪代码管理器中测试数据层变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google跟踪代码管理器中,我设置了一些数据层变量.我怎样才能像预期的那样测试数据是否通过这些变量输入?因此,我想验证数据是否已收集在dataLayer对象中(可以使用Firebug等完成),但更重要的是,我想知道GTM正在接收数据,并且宏和规则是按预期执行,等等.

In Google Tag Manager, I have some data layer variables set up. How can I test that the data is coming in through these variables as I expect? So, I want to verify that the data is getting collected in the dataLayer object (which can be done with Firebug, etc), but more importantly, I want to know that GTM is receiving the data, that the macros and rules are executing as expected, etc.

因此,在网站上,我有一些类似这样的代码:

So, on the website, I have some code like this:

dataLayer = [];

dataLayer.push({
    'city': 'city name',
    'state': 'state name',
    'subtotalCost': 'subtotal $',
    'salesTax': 'sales tax $'
});

然后,在此之后,我有加载gtm.js的GTM代码.这似乎已正确实现,但是,我想测试数据层变量的值是否按预期通过.我在哪里可以查看?

And then after this, I have the GTM code that loads gtm.js. This seems to be implemented correctly, however, I want to test that the values for the data layer variables are coming through as expected. Where can I check this at?

推荐答案

控制台是您的朋友.我要做的是在dataLayer.push之后的控制台中键入dataLayer,然后单击数组中的最后一个对象,您将看到自己的值.

The console is your friend. What I would do is type dataLayer into the console after dataLayer.push, then click on the last object in the array and you'll see your values.

例如,我将dataLayer.push放在一个onclick事件上并运行了dataLayer并能够看到这一点.当然,它们是静态值,但您会明白的.

For instance, I put the dataLayer.push on an onclick event and ran dataLayer and was able to see this come through. Granted they are static values, but you get the idea.

更新:

Google跟踪代码管理器已更新了其调试器,可让您查看NamesValues都已传递到GTM.

Google Tag Manager has updated their debugger, allowing you to see both Names or Values being passed into GTM.

这篇关于如何在Google跟踪代码管理器中测试数据层变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆