Thanks. I did some research. I do have a simpler way of implementing this if someone is not familiar with config files or not having access to those files.
I can have a if condition that I can use when initializing segment i/o.
var apikey;
if (window.location.host === "dev.xyz.com") {
apikey = <api_key>;
} else if (window.location.host === "staging.xyz.com") {
apikey = <api_key>;
} else if (window.location.host === "prod.com") {
apikey = <api_key>;
}
analytics.load(apikey);
Replace with respective api_keys from segment I/o . This works well.