In our last article, we showed you how to set up Google Analytics. Google Analytics is the best service to get the perfect stats for your website and blog for free. It’s free to use and is better than every single service of its kind. If you don’t have a Google Analytics account then click here.
In this tutorial, I’ll show you how to add your Google Analytics tracking code to your WordPress website. There are 3 ways to install Google Analytics in WordPress.
With A Plugin
If you’re don’t wanna mess around with codes, then it’s the best way for you. Google Analytics plugin by Kevin Sylvestre is the perfect one for this simple task.
Direct Paste Method
You can also directly paste the track code to current theme’s header.php right after the <body> tag.
With functions.php
This is my favorite method for every WordPress related task. Add the following code in your current theme’s functions.php file:
add_action('wp_footer', 'add_googleanalytics'); function add_googleanalytics() { ?> // Paste your Google Analytics code right here <?php }
Don’t forget to replace the third line of the above code with your Google Analytics tracking code.