I would like to add to the solution that I mentioned above. For the Google Analytics tracking code part, there may not be a need for freelancers if you can follow the instructions below with the use of a JS code snippet plug-in. I’ve developed a script that you can use.
Step 1:
Get a plug-in that allows you to insert a JS code snippet such as
CSS & JavaScript Toolbox
https://www.ads-software.com/plugins/css-javascript-toolbox/
Step 2:
Follow the first example of the video tutorial in the plug-in page above to insert a Google Analytics tracking code snippet.
In the code area, insert the following:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_MEASUREMENT_ID');
</script>
<script>
switch( window.location.hostname )
{
case "domain1.com":
document.head.innerHTML = document.head.innerHTML.replace(/GA_MEASUREMENT_ID/g, 'GA_MEASUREMENT_ID_FOR_DOMAIN_1');
break;
case "domain2.com":
document.head.innerHTML = document.head.innerHTML.replace(/GA_MEASUREMENT_ID/g, 'GA_MEASUREMENT_ID_FOR_DOMAIN_2');
break;
case "domain3.com":
document.head.innerHTML = document.head.innerHTML.replace(/GA_MEASUREMENT_ID/g, 'GA_MEASUREMENT_ID_FOR_DOMAIN_3');
break;
default:
break;
}
</script>
Step 3:
In the above code, replace each of
case "domain1.com"
and GA_MEASUREMENT_ID_FOR_DOMAIN_1
case "domain2.com"
and GA_MEASUREMENT_ID_FOR_DOMAIN_2
case "domain3.com"
and GA_MEASUREMENT_ID_FOR_DOMAIN_3
with the actual domain
and the actual Google Analytics tracking code GA_MEASUREMENT_ID
for each domain.