I’m trying to do the same thing. Most of our sites are custom using CI/CD for deployment, so webflow seems lacking in this area.
The if statement would work but it just doesn’t seem the right way to do it. Google tag manager might work to use different scripts but you’d still need a way to set the DTM-xxxxx per env.