Implement Onetrust cookie law into Vue project

Viewed 1057

Anyone have experience with implementing cookie low from Onetrust into some Vue projects? I'm interest about what is the best approach and not by adding the script in directly into index.html. My current implementation is by creating the script in App.vue and inject it on created method. Inject function looks like this:

  let oneTrustScript = document.createElement('script');
  oneTrustScript.setAttribute('src', parameters.oneTrustCookieCDN);
  oneTrustScript.setAttribute('type', 'text/javascript');
  oneTrustScript.setAttribute('charset', 'UTF-8');
  document.head.appendChild(oneTrustScript);

  // Run 
  let oneTrustFct = document.createElement('script');
  oneTrustFct.setAttribute('type', 'text/javascript');
  oneTrustFct.innerText = 'function OptanonWrapper() {}';
  document.head.appendChild(oneTrustFct)

The only issue is that if I accept the consent in homepage, after user is login through a 3rd party SSO, the cookie banner is displaying again on the authenticated homescreen.

Thanks in advice.

0 Answers
Related