That's why Theme-agnostic functionality such as tracking code should be added as a Plugin, rather than as part of the Theme, as well as why Themes should generally limit themselves to presentational, rather than functional, code.