I know there are many different ways you can include the Google Analytics script into a WordPress website, but I won’t use plugins for this.

So the way I would like to prefer is to code it into the theme’s functions file, giving me two options left. (yes it’s a child theme)

creating a function with analytics script inside, linking this to header/footer

using the default way WordPress asks to enqueue scripts at wp_enqueue_scripts

The outcome of the above ways will be different so with my little WordPress experience, I was wondering what should be the safest and most secure way to embed it into a WordPress site? Eventually I might consider also the difference in loading time, also the fastest way?