dataLayer.push 后数据何时发送到谷歌 [英] When does data get sent to google after dataLayer.push

查看:38
本文介绍了dataLayer.push 后数据何时发送到谷歌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个单页电子商务应用程序,需要设置谷歌电子商务渠道.我的应用程序在跟踪代码管理器数据层中设置了漏斗步骤

I have a single page ecommerce application and need to setup the google ecommerce funnel. My application sets the funnel steps in the Tag Manager dataLayer

文档中没有任何内容表明数据层何时实际发送到 Google 跟踪代码管理器.

Nothing in the documentation indicates when the datalayer is actually sent to Google Tag Manager.

window.dataLayer 开始页面:

window.dataLayer starts the page with:

  event: 'checkout',
  ecommerce: {
    checkout: { actionField: {step: 1, option: 'Checkout Options'}}
  }

点击第一个按钮

$(document).one('click','#button-payment-address', function () {
        window.dataLayer.push({
            'event': 'checkout',
            'ecommerce': {
                'checkout': {
                    'actionField': {
                        'step': 2,
                        'option': 'Billing Details'
                    }
                }
            }
        });
}); 

数据层变为:

event: 'checkout',
ecommerce: {
    checkout: { actionField: {step: 2, option: 'Billing Details'}}
}

在第二个按钮上

$(document).one('click', "#button-shipping-address",  function(){
        window.dataLayer.push({
            'event': 'checkout',
            'ecommerce': {
                 'checkout': {
                    'actionField': {
                       'step': 3,
                       'option': 'Delivery Details'
                    }
                }
            }
        }); 
        console.log(window.dataLayer);
}); 

数据层变为:

  event: 'checkout',
  ecommerce: {
    checkout: { actionField: {step: 3, option: 'Delivery Details'}}
  }

等等……

dataLayer 什么时候发送或者有什么方法可以强制发送,重新初始化 dataLayer 然后推送下一步?

When does the dataLayer get sent or is there a way to force a send, reinitialize the dataLayer and then push the next step?

更新:我在 Firefox DevTools/network/XHR 下查看流量,但没有找到.在 DevTools/network/images 下查看显示每次点击时发布的数据.

UPDATE: I was looking under Firefox DevTools/network/XHR for the traffic and could not find any. Looking under DevTools/network/images shows the data being posted on each click.

推荐答案

向 dataLayer 添加数据不会将其发送到任何地方.它只是在 GTM 中以结构化的方式提供数据.每当您将名为事件"的键推送到 dataLayer 时,GTM 会扫描 dataLayer 结构并使用更改或添加的值更新其内部数据模型.

Adding data to the dataLayer does not send it anywhere. It just makes the data available in a structured fashion from within GTM. Whenever you push a key named "event" to the dataLayer, GTM scans the dataLayer structure and updates its internal data model with the changed or added values.

这基本上为您的变量创建了一个命名空间.变量可以被覆盖,所以每次创建新的 JS 变量时,您需要确保不要重复使用现有名称并意外地为变量分配新值等等.相反,如果您将数据添加到 dataLayer,那么您只需注意不要有第二个 dataLayer 变量.

This creates basically a namespace for your variables. Variables can be overwritten, so you need to make sure that you do not re-use an existing name and accidentally assign a new value to a variable, and so on, every time you create a new JS variable. If instead you add data to the dataLayer, then you have just to take care that you do not have a second dataLayer variable.

话虽如此,您的情况有些不同.您拥有的是 Google Universal Analytics Enhanced E-Commerce 的特殊数据结构.至少应将您的 Google Analytics 综合浏览量或事件标记之一配置为启用增强型电子商务,并设置从数据层中提取数据.

Having said that, your case is somewhat different. What you have is a special data structure for Google Universal Analytics Enhanced E-Commerce. At least one of of your Google Analytics pageview or event tags should be configured to have enhanced e-commerce enabled, with the setting that pulls the data from the datalayer.

如果您在 GTM 中没有标签,则根本不会发送数据.

If you don't have tags in GTM, then the data will not be sent at all.

这篇关于dataLayer.push 后数据何时发送到谷歌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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