While there are numerous Google Analytics and Google Tag Manager plugins for WordPress, there is a simple way to add the Google analytics or tag manager code right within OceanWP with Ocean Hooks.
This example is for Google Tag Manager but Analytics first code segment goes in WP Head and because the segment should be at the top of <body> Before Top Bar is where the second code piece goes.
You can use the same method for other themes that support hooks like Genesis, Astra, Generatepress and others.