Include custom scripts (for example Iubenda)

For Workes & Pages, what is the name of the domain?

deselegnami.it

What is the issue or error you’re encountering

I’m trying to insert Iubenda with Zaraz but I’m still encountering the error I attached.

What are the steps to reproduce the issue?

Zaraz > Tools Configuration > Custom HTML > Placed this code

Screenshot of the error

1 Like

My empathy goes out to OP. I can’t give an answer, but can at least add one more to the tally of folks struggling with this. It would be very useful to have a good example in docs of this approach, or some recommendation against, if unfeasible. I’ve tried to rig up Iubenda scripts through Zaraz in the past with no luck. If there’s a proper way to do this with Zaraz, I would love to see it, and would implement it in my work right away. I went back to just using the Iubenda scripts in the head of my Next.js app. Good luck, and if someone else has a good idea here, it’s going to be much appreciated.

1 Like

This is not something we can help with when the report merely includes a JavaScript error that is not even coming from Zaraz. Please at least include the Custom HTML code you’re trying to insert.

Here is my code, if I insert it manually in the head tag I don’t get any error message

<script type="text/javascript">
  var _iub = _iub || [];
  var lang = document.documentElement.lang;

  var config = {
    "siteId": 3810411,
    "storage": { "useSiteId": true }
  };

  if (lang === 'it-IT') {
    config.cookiePolicyId = 49040907;
    config.lang = "it";
  } else if (lang === 'de-DE') {
    config.cookiePolicyId = 75594431;
    config.lang = "de";
  }

  _iub.csConfiguration = config;

  function loadScript(src) {
    var script = document.createElement('script');
    script.src = src;
    script.async = true;
    script.defer = true;
    document.head.appendChild(script);
  }

  loadScript("https://cs.iubenda.com/autoblocking/3810411.js");
  loadScript("//cdn.iubenda.com/cs/gpp/stub.js");
  loadScript("//cdn.iubenda.com/cs/iubenda_cs.js");
</script>