</head> tag on your site. Thats a tricky thing if you are using WordPress as CMS in your site. Because it is almost impossible to put the code on every page of WordPress blogs.
So where to put the Google Analytics code in WordPress? Well, here is a quick fix. You need to just add the analytics code to head section of your pages. To this, WordPress gives you an action hook – wp_head. Write a custom function and hook it to wp_head action hook. Here is a custom function which you can add to your child-theme‘s functions.php file. Since it is a php function, you need to put this anywhere between opening and closing php tags (between
<?php and ?>)
Replace UA-XXXXXXXX-X with your actual Google Analytics code.
If you are using a WordPress theme which never gets an update from WordPress.org theme repository, you can directly edit
header.php of your theme to insert Google Analytics code. To do this just open up the
header.php file and paste your Google analytics code just above the
header.php can be found in
Dashboard --> Appearance --> Editor --> footer.php. If you don't have the access to edit the file there, then go to
root/wp-content/themes/yourcurrenttheme/ directory in file manager and edit
Follow these topics Technology, WordPress