Questions about editing index.html in the theme/web folder

Iv added an index.html file to the theme/web folder to allow me to add google tag analytics to the head and bosy of the web page but i have the following questions about doing so:   what happens if the layout/theme updates, do we loose the index.html file? is there a way to run these scripts only on prod. by using an environment variable for example?
1 answers

I believe the index.html in your theme folder will always overwrite the index.html generated from the mendix deployment process. 

You can use JS within script tags to for instance access the remoteUrl to determine the environment.