How to insert something right after <head>?

For a GDPR solution, I need to insert a script tag right after the opening <head> tag.

Is there a simple way to achieve that?

Building a component only allows me to insert it before the closing </head> tag.

1 Like

If you go to the theme CSS section, you will be able to do what you need to do.

3 Likes

The CSS field does not accept a <script type="text/javascript" src="https://app.xxxx.ai/script/xxx.js"></script> tag.

The browser doesn’t really care whether the script tag is added right after the opening <head> tag or right before the closing </head> tag. It will load it anyway and the result would be the same. The only thing that this affects is execution order (which doesn’t really matter in your case).

Further, your users also wouldn’t care about that since the <head> tag is not supposed to contain any user content (text, images, etc…) and is to set display: none in all browsers.

Please try to add your script tag to the </head> tab in your component and then whitelist the source of that script in CSP. If you run into any problems related to that, we can help :+1:

6 Likes