Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialUnsubscribed User
3,136 Pointssetting up analytics?
in the description for this course: Wordpress for website owners, you spoke about walking through setting up website analytics....this is the end of the course and there's nothing on setting up website analytics covered
1 Answer
Sue Dough
35,800 PointsThere is a few ways.
- Paste the tracking code into your header.php
- Yoast https://wordpress.org/plugins/google-analytics-for-wordpress/ or any other wordpress google analytics plugin.
- Putting in your functions.php file with a code like this below:
<?php add_action('wp_header', 'add_google_analytics');
function add_google_analytics() { ?>
// Paste your Google Analytics code here
<?php } ?>
There is pros and cons to every way:
- Is not the best way to do it but a "quick fix" . If you update or change your theme, chances are you will lose this code if its in the main theme file.
- 3rd parties could potentially gain access to data besides google by using a plugin which is a major con. The other major con is its a plugin! You don't want plugins when you don't have to.
- This is the best way in my opinion and probably the most professional. You could do it in a child theme as well so you don't lose any changes.