
The Following below admin setting required to add Google Analytics Code in Magento 2 Store.
Step [1] – Go STORES > Configuration, redirects Configuration section.

Step [2] – Left panel, choose SALES > Google API

Step [3] – Right panel, Expand the Google Analytics section.
To Enable select Yes, after uncheck use system value

Enter the Tracking ID in Account Number
Step [4] – Click on Save Config button & run CLI command Flush