Service Portal <head> tag

aswinsiddaling1
Kilo Explorer

Hi All,

We are trying to integrate ServiceNow with Cookie Compliance on one of our public-facing Service Portal. To implement this, we need to embed the Cookie Compliance script (basically as <script> tag) inside the <head> tag of the Service Portal page (or) we need to make sure that the Cookie Compliance script is executed as the first script on load of the Service Portal page before any other script can run.

Please let me know if this is feasible (or) if you have any suggestions on implementing this.

2 REPLIES 2

Siva Sandilya
Kilo Contributor

Hi,

 

if you are using any widget, You can copy the script to UI script and set it as dependency.

 

Regards,

Sandilya.

sonjaroth
Giga Contributor

We had the same challenge, the following approach worked for us:

1. Create UI Script with following Code (With help of this Community Post)

(function() {
	
    var top = document.querySelector('head'); // reach out to the parent window and get the head element

    var script = document.createElement('script'); //create a new script element

    script.src = 'https://app.usercentrics.eu/latest/main.js'; //sets the src attribute

    script.type = 'application/javascript'; //sets the type attribute

    script.id = 'XXX';

    top.appendChild(script); // appends the newly created script element at the end of the top window head element

})();

2. Go to your Theme Record and create a new JS Include. Select there the UI script.

Result: We have the following <script> Tag in the <head> Tag:

find_real_file.png