Cookie blocked by firewall

Hello Piwik community,

I have added the tracking cookie to a website for a customer. However the firewall in our Azure environment blocks this cookie because it is in JSON and some parts look similar to small parts of an SQL query.

Excluding this cookie from the firewall seems like the last option. Preferably I want to change this cookie in such a way so that it can pass the firewall. I thought about encoding the cookie value in base64. This does not seem possible from what I have seen in the documentation.

Has anyone managed to do something like this?

This is the setup that I use.

            (function (window, document, dataLayerName, id) {
              window[dataLayerName] = window[dataLayerName] || [], window[dataLayerName].push({
                  start: (new Date).getTime(),
                  event: "stg.start"
              });
              var scripts = document.getElementsByTagName('script')[0], tags = document.createElement('script');
          
              function stgCreateCookie(a, b, c) {
                  var d = "";
                  if (c) {
                      var e = new Date;
                      e.setTime(e.getTime() + 24 * c * 60 * 60 * 1e3), d = "; expires=" + e.toUTCString();
                      f = "; SameSite=Strict"
                  }
                  document.cookie = a + "=" + b + d + f + "; path=/"
              }
          
              var isStgDebug = (window.location.href.match("stg_debug") || document.cookie.match("stg_debug")) && !window.location.href.match("stg_disable_debug");
              stgCreateCookie("stg_debug", isStgDebug ? 1 : "", isStgDebug ? 14 : -1);
              var qP = [];
              dataLayerName !== "dataLayer" && qP.push("data_layer_name=" + dataLayerName), isStgDebug && qP.push("stg_debug");
              var qPString = qP.length > 0 ? ("?" + qP.join("&")) : "";
              tags.async = !0, tags.src = "<customer-url>" + id + ".js" + qPString, scripts.parentNode.insertBefore(tags, scripts);
              !function (a, n, i) {
                  a[n] = a[n] || {};
                  for (var c = 0; c < i.length; c++) !function (i) {
                      a[n][i] = a[n][i] || {}, a[n][i].api = a[n][i].api || function () {
                          var a = [].slice.call(arguments, 0);
                          "string" == typeof a[0] && window[dataLayerName].push({
                              event: n + "." + i + ":" + a[0],
                              parameters: [].slice.call(arguments, 1)
                          })
                      }
                  }(i[c])
              }(window, "ppms", ["tm", "cm"]);
          })(window, document, 'dataLayer', '<id>');

Hi,
Welcome to the community!

Unfortunately, there is no custom or native solution that we support that would help you overcome this.

The issue steems from this specific firewall, so what we would recommend and what seems to be the most plausible solution here would be to whitelist the Piwik PRO cookies using the firewall’s UI.

1 Like

Thanks. I’ll discuss this with the customer