Service Portal <head> tag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2019 11:08 PM
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.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2019 11:13 PM
Hi,
if you are using any widget, You can copy the script to UI script and set it as dependency.
Regards,
Sandilya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2020 02:03 AM
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: