There are a lot of different scenarios where you may want to add scripts onto your site. It's best practice not to directly edit the theme, as that may introduce issues with future updates.
We recommend using a plugin as a simple and easy way to add any scripts you want to include on your site, rather than inserting code directly into the content editor, or editing the templates.
This plugin works well: https://wordpress.org/plugins/scripts-n-styles/
The plugin allows you to add scripts into either the header or footer, that will appear on every page - or if you go to the Edit Page screen for a specific page, you can add code just for that page.
The Hoops Feature
In addition to the basic option to add header/footer scripts, one unique option is the "Hoops" feature in the plugin. It basically allows you to make a shortcode out of anything. Here is how to use it:
1. Enable the plugin, and go to Tools > Scripts n Styles, and the Hoops tab
2. Give your hoop a name, and then copy/paste in the whole block of code into the textarea
3. Save that, and it will provide a shortcode below
4. Then you can copy/paste that shortcode wherever you want it to appear, such as in an Elementor widget - the Shortcode widget works well.
If you have any questions, please feel free to open a ticket.