最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - dataLayer.push() return value meaning - Stack Overflow

programmeradmin1浏览0评论

I'm struggling to implement Google Tag Manager at my job, I do have the problem that the administrator console is not available so I got to trust that the configuration is correct.

Anyway, I initialized the dataLayer array, I included the GTM script and now some events are getting sent to Google.

Enhanced e-commerce is enabled, but if I copy paste onto my console the following snippet (Taken from "" ):

dataLayer.push({
  "event": "checkout",
  "ecommerce": {
    "checkout": {
      "actionField": {
        "step": 1
      },
      "products": [{
        "id": "b55da",
        "name": "Flexigen T-Shirt",
        "price": "16.00",
        "brand": "Flexigen",
        "category": "T-Shirts",
        "variant": "red",
        "dimension1": "M",
        "position": 0,
        "quantity": 1
      }]
    },
    "promoView": {
      "promotions": [{
        "id": "bts",
        "name": "Back To School",
        "creative": "CHECKOUT right",
        "position": "right sidebar"
      }]
    }
  }
});

I'm struggling to implement Google Tag Manager at my job, I do have the problem that the administrator console is not available so I got to trust that the configuration is correct.

Anyway, I initialized the dataLayer array, I included the GTM script and now some events are getting sent to Google.

Enhanced e-commerce is enabled, but if I copy paste onto my console the following snippet (Taken from "https://enhancedecommerce.appspot.com/checkout" ):

dataLayer.push({
  "event": "checkout",
  "ecommerce": {
    "checkout": {
      "actionField": {
        "step": 1
      },
      "products": [{
        "id": "b55da",
        "name": "Flexigen T-Shirt",
        "price": "16.00",
        "brand": "Flexigen",
        "category": "T-Shirts",
        "variant": "red",
        "dimension1": "M",
        "position": 0,
        "quantity": 1
      }]
    },
    "promoView": {
      "promotions": [{
        "id": "bts",
        "name": "Back To School",
        "creative": "CHECKOUT right",
        "position": "right sidebar"
      }]
    }
  }
});

the console returns "true" and no data is being sent to GTM.

My question is, what does the return value mean in GTM, and, can I get to know the reason why the GTM tag is not sending data when I push a checkout event?

Just to clarify, this other snippet works, returns false and sends data to google.

dataLayer.push({
  "event": "addToCart",
  "ecommerce": {
    "currencyCode": "USD",
    "add": {
      "products": [{
        "id": "b55da",
        "name": "Flexigen T-Shirt",
        "price": "16.00",
        "brand": "Flexigen",
        "category": "T-Shirts",
        "variant": "red",
        "dimension1": "M",
        "position": 0,
        "quantity": 1
      }]
    }
  }
});

Share Improve this question asked Apr 26, 2016 at 9:59 BorjanteBorjante 10.5k6 gold badges39 silver badges63 bronze badges 2
  • They actually don't, on the enhancedecommerced.appspot.com site it returns false when succesfull – Borjante Commented Apr 26, 2016 at 13:49
  • I'm pretty sute the GTM container ain't setup correctly, that's true, but I the return of the push() function is bothering me – Borjante Commented Apr 26, 2016 at 13:50
Add a comment  | 

1 Answer 1

Reset to default 22

The return value, assuming you are referring to when you pasted the code into the console, indicates whether a GTM tag fired in response to the push. "true" means that no tags fired, and "false" means that a tag fired.

To get a tag to fire based on a data layer push, you need to leverage the value of the event key as your trigger for your tags. You probably have a trigger with addToCart to for a tag, so do the same thing with the checkout event.

发布评论

评论列表(0)

  1. 暂无评论