Pushing URL parameter as custom dimension not working anymore after upgrade to Matomo 4.7.1

We are extracting URL parameters and pushing them as custom dimension to Matomo 4.7.1. We have our tracking code in Matomo Tag manager as custom HTML and then publish the corresponding container on our website.
The tracking code that we use is

<!-- MATOMO --->	
<script type="text/javascript"> var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
var url = new URL(window.location.href);
var params = new URLSearchParams(document.location.search.substring(1));
if (params.get("gclid")) {
/* _paq.push(['setCustomDimension', customDimensionId =1, customDimensionValue = params.get("gclid")]); */
_paq.push(['setCustomDimension', 1, params.get("gclid")]);
if (params.get("fbclid")) {
_paq.push(['setCustomDimension', 1, params.get("fbclid")]);
if (params.get("genclid")) {
_paq.push(['setCustomDimension', 1, params.get("genclid")]);
if (params.get("pk_cid")) {
_paq.push(['setCampaignNameKey', "pk_cid"]);
if (params.get("djid")) {
/*_paq.push(['setUserId', params.get("djid")]); */
_paq.push(['setCustomDimension', customDimensionId =2, customDimensionValue = params.get("djid")]);
if (params.get("pk_keyword")) {
_paq.push(['setCampaignKeywordKey', "pk_keyword"]);
_paq.push(['setCustomUrl', url.href]);
 _paq.push(["setCookieDomain", "XXX.de"]);
  _paq.push(["setDomains", "XXX.de"]);
_paq.push(['setSecureCookie', true]);
  (function() {
    var u="https://matomo.XXX.de/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '4']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
<!-- End Matomo Code -->

Actual domains are X’ed out on purpose. Any suggestion on what might have broken with the upgrade is highly welcome.

We found that actually our tracking code was wrongly published on the website. This ticket can therefore be closed.