Install Analytics on Your WordPress Site Without Installing a Plugin
Before we start the process, first make sure you run backups for your WordPress theme, so if any problem happens, you can restore your theme back anytime.
You’ll need to be extra careful while editing the code that outputs your WordPress website. Any slight mistake made with the code would be capable of pulling down your site. Ensure you run a backup first before you begin installation.
Step 1: Obtain Your Analytics Global Site Tag (Tracking Code)
Start by logging into your Analytics account and choose the site on which you want to install the global site tag.
Move your mouse cursor to the left taskbar and click on Admin.
Choose the Tracking Info button through the property column, then the Tracking Code.
Under the Website Tracking section, you’ll find your Google Analytics tracking code. Just copy your code.
Step 2: Locate the Header.php File and Add the Analytics Tracking Code
Log into your WordPress back office and scroll down to Appearance, and then click on Editor. Click on the header.php file which is located below the Templates tab.
Right before the closing </head>, paste the copied Analytics tracking code, and then click on the Update File button. Make sure the file is edited successfully. If you don’t want to risk bringing down your website, then ask your hosting provider to assist you with pasting the tracking code.
That’s all!