yireo/Yireo_GoogleTagManager2

yireoGoogleTagManager::isAllowedByCookieRestrictionMode always returns true

Closed this issue · 0 comments

Just installed the extension and at quick glance seems to me that https://github.com/yireo/Yireo_GoogleTagManager2/blob/master/view/frontend/web/js/generic.js#L38C9-L38C41 always returns true

Case scenarions:

  1. Visiting the page in Incognito (after browser's storage flush) when user_allowed_save_cookie is not set returns undefined which is later on confusing isDisabled function
  2. Visiting the page after clicking consent button - here returned value is an object so, again isDisabled won't work

Possible solutions:

  1. Extending components moduleConfig - fetching current website id and using it later on...
  2. Quick fix - something like:
var isAllowedByCookieRestrictionMode = function () {
        if (!moduleConfig.cookie_restriction_mode) {
            return true;
        }
        const websiteId = window.checkout.websiteId;
        const parsedCookie = JSON.parse($.cookie(moduleConfig.cookie_restriction_mode) || '{}');

        return parsedCookie[websiteId] || false;
};

but this will probably break Hyva compatibility because of window.checkout