You can use a plugin named Header and Footer Scripts Inserter to add the Google Analytics code to your site. Go to Plugins → Add New on the WordPress menu, and search for Header and Footer Scripts Inserter.
Once installed go to Settings → Header and Footer Scripts Inserter on the WordPress menu. You can add the Google Analytics code to either the header or footer of your site (it will work anywhere).