There are a couple of plugins which help you to do this, but we’ve found the simplest way is to add the Google Analytics code to the header.php file just before the closing tag.
In your WordPress admin hover over Appearance -> Click Editor
Find the header.php file on the right side
And paste your Analytics code (including the script tags) right before the closing head tag.