WordPress Theme Script Layer Editing
https://www.cloudways.com/blog/add-google-analytics-to-wordpress/
- If you already have the website, then go to the WordPress dashboard.
- Click Appearance → Editor.
- Click the “header.php” file to edit its code.
- Copy the “Tracking Code” from Google Analytics and paste it into the header code. Ensure to paste the code right before the </head> tag.
From link.