Running on-page A/B testing in-house with Google Analytics

While I’m aware of tools like Optimizely, I wanted to run A/B tests on my site without having to use an external tool to run the modifications. The main reason for not using Optimizely or another off-the-shelf software was because I didn’t want to load their javascript on my site. Besides, I wanted complete control over how I wanted to render those variations. I then came across Google’s guide to running content experiments using google analytics with Javascript to create on-page variations.