Hello Friends today I am going to share how to add google analytics code on your wordpress website using hooks in functions.php, To do so you can use wp_head hook. The wp_head action hook is triggered within the <head></head> tag. You can also use lots of available plugins but that makes your website heavy so for small features/functionality it is better to use fuctions.php.
So here is the code
1 2 3 4 5 6 7 8 9 10 |
//Google Anylytics Tracking Code add_action( 'wp_head', 'analytics_tracking_code' ); function analytics_tracking_code() { ?> <script> //paste your google analytics tracking code here </script> <?php } |
Thanks 🙂
Please share if you like it
Comments