The topic at Set up Google Tag Manager for use with Google Analytics describes how to setup Google Tag Manager on Discourse. We seem to be missing a howto topic that deals with just setting up Google Analytics.
If you are not using Google Tag Manager, all you need to do to setup Google Analytics is add your Google Analytics tracking code to the Discourse ga universal tracking code
site setting, and your domain name to the ga universal domain name
site setting. When the ga universal tracking code
site setting is set, Discourse will automatically load the analytics script.