You can setup your WordPress site with Google analytics using a plugin, instead of manually entering the tracking code into your files. A plugin that helps with this process is the Google Analytics for WordPress by MonsterInsights plugin.
Remember, whenever you're deciding on a new plugin be sure to check the developer's page to determine if they're still maintaining the plugin with updates.
If you don't already have a Google Analytics account setup, then you will first need to set one up.
- Log in to WordPress.
- Install the plugin.
- Activate the plugin.
- Locate the new sub menu in your main Settings menu labeled Insights, and click it.
- Click Settings under Insights.
- Click Authenticate with your Google Account.
- Click Next.
- Click Click to Get Google Code
- If necessary, login to your Google account when prompted.
- Click Allow
- Copy the code that is provided.
- Return to the browser window with your Insights settings and paste the code where it says "Paste Google Code Here".
- Click Next.
- Select the Google Analytics profile you want to use.
- Click Next.
- Click Close.
More info