This is what I do:
{{ if eq (getenv "HUGO_ENV") "production" }}
{{ template "_internal/google_analytics_async.html" . }}
{{ end }}
which of course, means in production, you set your environment to production. On the command line it looks like this: HUGO_ENV="production"