- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在添加到 dayaLayer 时遇到问题。对于 gtm 我使用这个 plugin ,但是不明白怎么通过组件为其添加dataLayer。
我的 nuxt.config fo 插件
modules: [
['@nuxtjs/google-tag-manager', {
id: 'GTM-xxxxxxxxxx',
pageViewEventName: 'nuxtRoute',
pageTracking: true,
layer: 'dataLayer'
}]
]
head() {
return {
title: this.seo.title_meta,
meta: [
// hid is used as unique identifier. Do not use `vmid` for it as it will not work
{ hid: 'google-site-verification', name: 'google-site-verification', content: 'test' },
{ hid: 'description', name: 'description', content: this.seo.description_meta }
],
__dangerouslyDisableSanitizers: ['script'],
script: [
{
innerHTML: JSON.stringify({
'@context': 'http://schema.org',
'@type': 'Organization',
name: 'test',
url: 'https://test.co',
sameAs: this.linkMeta,
description: `${this.seo.description_meta}`
}),
type: 'application/ld+json'
},
{
innerHTML: `
window.dataLayer = window.dataLayer || [];
window.dataLayer = [{ 'pageType': 'Main'}]
`
}
]
};
},
最佳答案
在您的 nuxt.config.js 中,您需要将此添加到 head
目的:
script: [
{
hid: 'gtm',
innerHTML: `window.dataLayer = window.dataLayer || [];`,
type: 'text/javascript'
}
]
比在您的 nuxt 页面中,您可以使用挂载的钩子(Hook)将数据推送到 dataLayer,如下所示:
mounted: {
window.dataLayer.push({variable: value, someOtherVar: anotherValue})
}
使用挂载的钩子(Hook)很重要,因为这个钩子(Hook)被称为 wenn asycData() 或 fetch() 已经完成并且应用程序是水合的,因此窗口可用。
关于vue.js - 如何将 gtm dataLayer 添加到 nuxt.js 组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59880855/
我正在 build WP website using DIVI theme .应该被插入 dataLayer 的标签被默认的“未设置”值卡在某个地方。 为了推送我使用脚本的值: functi
我正在尝试为我的网站创建一个数据层,但遇到了这个问题。据我了解:Google 跟踪代码管理器 dataLayer 就是这样工作的,因此您拥有一个包含所有数据变量的 dataLayer 对象。每次您使用
哪一个更优化? 我有一个感谢页面,我需要将所有交易销售信息加载到此页面中,以便通过 Google 跟踪代码管理器将其发布到 Google Analytics(分析)。 我是否使用下面的代码声明 dat
我正在尝试推送dataLayer。但是它一直给我一个重复的数组。请看下面我的代码 dataLayer = [{ 'productID': '123456', 'productTitle':
我想将数据从 HTML 代码提取到我的数据层(Google 跟踪代码管理器)中。 html代码是这样的: ... Javascript 代码是这样的: var lang_log = docume
我正在寻找有关 jQuery 的一些方向。可能有更好的方法来做到这一点,但基本上我试图在用户滚动到页面的 50% 时发送一个 dataLayer 变量,并在用户滚动到页面的 75% 时发送另一个变量。
我需要建议。目前,我有网站。主页上有书签,无需重新加载页面(onclick)。通常我不会有问题,但我无法捕获有关书签的相关数据,如 elementID、elementClasses 等(不可能更改它)
我有一个单页电子商务应用程序,需要设置 Google 电子商务 channel 。我的应用程序在跟踪代码管理器数据层中设置漏斗步骤 文档中没有任何内容表明数据层实际发送到 Google 跟踪代码管理器
进程文件: datalayer or datalayer.exe 进程名称: Nokia PC Suite 5 Component 进程类别:存在安全风险的进程 英文描述: datalaye
我想在 atalayer 中使用对象。我遵循了开发人员文档,他们展示了一个平面数据模型。我想推送一个潜在客户对象并在用户将信息输入潜在客户表单时对其进行更新。 与公司、规模和位置、关键和值(value
在向我们的开发人员提供与GTM代码一起使用的dataLayer代码方面,需要一些建议。 如果dataLayer与容器标记代码一起出现在每个页面上,我如何为整个域中的许多事件定义所有变量? dataLa
我正在使用 Google 跟踪代码管理器自定义我的 GA 设置,我对该工具相当有经验,但今天被一些事情难住了。奇怪的是,标签不会被触发。它被设置为在点击具有特定类的元素时触发,如下所示: 调试后,我可
我在工作中努力实现 Google 跟踪代码管理器,我确实遇到管理员控制台不可用的问题,因此我必须相信配置是正确的。 无论如何,我初始化了 dataLayer 数组,我包含了 GTM 脚本,现在一些事件
我想知道为什么 gtag.js 在推送到 dataLayer 变量数组而不是“参数”时不起作用?下面是一些代码示例: window.dataLayer = window.dataLayer || []
我正在使用谷歌分析和谷歌标签管理器设置电子商务跟踪。 每一个产品详情页面,我也有一个列表——“家庭产品”和“类似产品”。 发送产品详细信息以及这两个列表的正确方法是什么?我正在使用不同的 dataLa
我在网站上为 Google Tag manager 设置了一些自定义标签来跟踪一些自定义数据,但它没有跟踪。 dataLayer 变量在标签管理器代码上方的头部整理了多个这样的数据。 过程是,用户登陆
我正在尝试将 JavaScript 变量传递到数据层。 $(document).ready(function() { var dataTag = $('#data-tag-li
如果我创建一个在 GTM 中的“页面 View ”上触发的标签,我可以在触发该标签后将数据推送到该标签吗? This is the event type I'm using (page view)
我希望有人可以帮助我弄清楚如何从用户在提交过程中在表单上选择的复选框中获取datalayer.push数据。该表单有很多字段,但我只想要已选中的复选框。 最佳答案 您需要检查何时调用dataLayer
是否可以在普通JavaScript中有效地观察数据层的变化?每次调用 dataLayer.push 函数时,我都需要了解此添加和检查添加到 dataLayer 的事件。我找不到任何解决方案。我需要像
我是一名优秀的程序员,十分优秀!