Add Google Analytics Tracking Code Using WordPress Hook
Forget the old fashion way of adding Google Analytics tracking code directly in footer.php or header.php of your WordPress website! We’re going to add the tracking code using WordPress hook. To make it work, add this codes to your functions.php file. Don’t forget to replace YOUR-TRACKING-ID text with your Google Analytics tracking ID.