As a best practice, Google Analytics tracking code should be added to your website on a general level, so you don’t need to re-enter the code when switching WordPress themes.
Add Google Analytics using a plugin
We strongly recommend that you use plugins to add your Google Analytics code.
Here is a list of some of the most popular (and free) plugins:
- Google Analytics for WordPress by MonsterInsights – https://wordpress.org/plugins/google-analytics-for-wordpress/
- Google Analytics Dashboard for WP – https://wordpress.org/plugins/google-analytics-dashboard-for-wp/
- Google Analytics GA – https://wordpress.org/plugins/wd-google-analytics/
- Google Analytics WD – https://wordpress.org/plugins/wd-google-analytics/
If you are already running a website that is powered by some of the most popular SEO plugins like All In One SEO Pack or WP Meta SEO etc, check their options as they are all offering a way to insert Google Analytics tracking code for easier visitors and performance tracking.