Skip to content
Advertisement

dataLayer.push() return value meaning

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
      }]
    }
  }
});

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement