yireo/Yireo_GoogleTagManager2

on checkoutpage the dalayer still get "Quote"

Closed this issue · 9 comments

Hi,
First thanks for that module.

I tested it on a clean install of magento 2.2.2 with defaut theme and sample data.

The datalayer contain all needed data, but when I validate the order and get redirected to /checkout/onepage/success
The datalayer is still in "quote" mode.
I have to visit an other page to get it in "Order" mode.

After a quick review of "network" panel I see a request to
http://magento.test/customer/section/load/?sections=yireo-gtm-quote%2Cyireo-gtm-order&_=1518707232232 with the status "canceled"

If I submit this request by hand, the datalayer goes well in "order" mode.
But I can't figure why I got this status "canceled".
If you got any tip to help to debug it.
Thanks

After some test to try to understand what can be wrong I see something strange...
on /checkout/onepage/success after complete an order the google tag manager helper say datalayer = quote, a console log of datalayer say quote.
But the call to section/load/?sections=yireo-gtm-quote%2Cyireo-gtm-order got a response with an "order".

I'm not a JS dev and new in M2 world... but in my mind it's like there isn't any "refresh" of the datalayer value after the call

yireo

didn't know if it's very usefull, perhaps i'm the only one to got this issue ?
if i go to an other page after the order, the data will be passed to google analytics, else we "lost" the transaction in GA.

Thanks

A small ping in between: I'm currently vacation and can't promise I can look into this before early March. I will try though.

Can you see if the latest release fixes this for you?

Thanks, it's seem to be ok (on local) will try on several instance asap.

I'm still having this problem with the latest version;
The success page is still showing the quote, but the next page I go to contains the order data (that also doesn't seem very right?)

I think the getCartSpecificAttributes function in generic.js should look more like this:

var getCartSpecificAttributes = function () {

    var cart = customerData.get('cart');
    var quote = customerData.get('yireo-gtm-quote');
    var order = customerData.get('yireo-gtm-order');

    // If the cart contains products we want the quote
    if (cart().summary_count > 0) {
        var quoteData = quote();
        delete quoteData.data_id;
        if (!_.isEmpty(quoteData)) {
            return quoteData;
        }
    }
    else {
        var orderData = order();
        delete orderData.data_id;
        if (!_.isEmpty(orderData)) {
            return orderData;
        }
    }

    return {};
};

The fact that after a successful order we are seeing the order on every page is Magento logic as they do not clear the lastOrderId on the session when leaving the success page. Because of this the CustomerData for the order will keep fetching the last placed order while your session remains active.

We're having similar issues (on version 0.3.9). But in our case the quoute nor the order data is added to the dataLayer on the success page. @koenner01 's fix seems to work in at least one of our environments. I'll check some others as well and report back.

I've now released version 0.3.10 with more or less the fix above. It still works in my environment, but having said that, so did the previous version ....

Closing due to inactivity