I need to add the latest Google Analytics (GA4) script to a site, for the business.
It is an ASP.NET Core MVC webapp so it's going in the _layout page.
There a few potential issues I see with the Measurement ID:
- It is visible to the public via the page source (so anyone could track the stats)
- It would require a code change if the production ID needs to change
- There is no difference between IDs for the development vs production environment
My question(s) is:
- In general is it worth putting the Measurement ID in to a config to alleviate the above conerns?
- What would the best practice way of achieving this e.g. appsettings.json, user secret?
Many thanks