We have a cookie consent theme component that makes adding a banner easier: Discourse Cookie Consent Banner
If you haven’t installed a theme before you’ll want to look at How do I install a Theme or Theme Component?
You can add your own custom scripts under admin > customize > themes
, but for a third-party script you’ll need to edit your site’s content security policy… there’s some detail here: Mitigate XSS Attacks with Content Security Policy