I'm seeing this error "Uncaught TypeError: w[l].push is not a function" in my Google Tag Manager javascript. What's going on?
我看到这个错误"未捕获类型错误:w[l]。在我的谷歌标记管理器javascript中,push不是函数。这是怎么呢
I'm using the normal GTM script, and I've got a simple dataLayer defined:
我使用的是普通的GTM脚本,我定义了一个简单的dataLayer:
<script>
dataLayer = {
"foo": "bar"
}
</script>
2 个解决方案
#1
8
dataLayer must be a list of objects, not an object.
dataLayer必须是对象的列表,而不是对象。
https://developers.google.com/tag-manager/devguide?hl=en
https://developers.google.com/tag-manager/devguide?hl=en
Instead of:
而不是:
<script>
dataLayer = {
"foo": "bar"
}
</script>
Use:
使用:
<script>
dataLayer = [{
"foo": "bar"
}]
</script>
#2
1
This error also occurs if you're using the dataLayer.push method with an = sign.
如果使用dataLayer的话,也会出现这个错误。用=号推方法。
Wrong: dataLayer.push = ({
Correct: dataLayer.push({
错误的:dataLayer。push =({正确:dataLayer.push)
#1
8
dataLayer must be a list of objects, not an object.
dataLayer必须是对象的列表,而不是对象。
https://developers.google.com/tag-manager/devguide?hl=en
https://developers.google.com/tag-manager/devguide?hl=en
Instead of:
而不是:
<script>
dataLayer = {
"foo": "bar"
}
</script>
Use:
使用:
<script>
dataLayer = [{
"foo": "bar"
}]
</script>
#2
1
This error also occurs if you're using the dataLayer.push method with an = sign.
如果使用dataLayer的话,也会出现这个错误。用=号推方法。
Wrong: dataLayer.push = ({
Correct: dataLayer.push({
错误的:dataLayer。push =({正确:dataLayer.push)