1. Create a new Hook Element.
2. Add your <script> to the Hook Content.
3. Select the Hook: wp_head
4. Set the Display Rule Location to Entire Site.
If you’re using Google Tag Manager it provides a second code for adding after the Body Open tag.
If you’re using GTM. Then repeat the above for the second code. And change the Hook to wp_body_open