google analytics and child theme
-
I use a child theme. I understood in this case the google code has to be inserted in the funcionts.php file. Therefore I realized I have two of this file. The first in Themes folder, the second in Theme-child folder.
Which one of the two?
Then Google recommend to use this code:
<script>
(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);ga(‘create’, ‘UA-XXXXXXXX-X’, ‘auto’);
ga(‘send’, ‘pageview’);</script>
I’ll add this code at the end of the file after } but before ?> ???
Then it seems someone use only
add_action(‘wp_footer’, ‘ga’);
function ga() { ?>
UA-XXXXXXXX-X
<?php } ?>Is it correct the code?
Thanks in advance!!!!!! 🙂
The topic ‘google analytics and child theme’ is closed to new replies.