A common usage of WordPress plugins is to add “JavaScript code or CSS files , CSS scripts in the head section of every WordPress page or post. In same way you can add Google Analytics codeĀ in WordPress. You can add JavaScript code in WP directly in header.php file or using a plugin. Both discussed in this tutorial.