How To Automatically Redirect Visitors Based On Their Country/IP

Very commonly with Shopify Plus (since they give you up to 3 stores for internationalization), we will need to redirect people to other sites based on where they are. So here is a script you can use to automatically redirect someone to a separate domain if they are from a certain country: