Hi all,
Can we still add our Google Analytics tracking code in Sage like we used to do in Roots?
What is the recommended way? I am not using the Soil plugin.
Regards,
Steven
Hi all,
Can we still add our Google Analytics tracking code in Sage like we used to do in Roots?
What is the recommended way? I am not using the Soil plugin.
Regards,
Steven
You have a couple options:
Grab the code from HTML5 Boilerplate and stick it in your base.php.
If you want a repeatable way to do it in your own sage fork or something where you only need to include the GA UA ID, go the old Roots route: wrap that HTML5BP <script>
code in a php function, make the “UA-XXXXX-X” bit a PHP CONSTANT you set somewhere and attach it to wp_footer
//in some file, even wp-config.php
define('GOOGLE_ID', 'UA-123456-7');
//and in config.php or setup.php
function includeGA(){ ?>
//<script> from boilerplate here
<?php } ?>
add_action('wp_footer', currentNAMESPACE .\'includeGA', 10);
I’ve taken to using CMB2 to make a site options form within the admin. I include a field for it there and pull that in.