How to add Google Analytics correctly

To add Google Analytics code in theme there are special options and their editing is available on theme settings page in admin panel of site.

Adding counters code in special option you receive guarantee that even after theme updating all connected earlier counters will be saved and will not be accidentally overwritten. This is main advantage of than simply edit files header.php or footer.php.

Go to menu Appearance Customize and select tab Custom codes

en_basic_customcodes

en_custom-css-basic

Here you can add your styles, scripts which won’t be lost while updating theme.

Google Analytics is recommended to add as close as possible to top of page, i.e. in site header. To do this, add code received from Google in first text box Scripts in header. Consequently, if you add these scripts in boxScripts in site footer, they will appear in site footer before closing tag </body>.

Field Custom styles will help you to style site with CSS code. It is important to remember that these styles will be added directly to page code, site header, for this reason they will have higher priority than styles which are defined in style.css. For example, if it is defined in style.css:

body{
    background-color:#ffffff;
}

and in field Custom styles you add:

body{
    background-color:#000000;
}

then the latest style will be applied and page background will be black.

After changing text boxes in section Custom codes, click on Save & publish. That’s all, added scripts or styles will appear on your site.