You can use any of these action hooks, depending on your preference for whether this code is added in the header or footer and whether it’s loaded before or after default scripts:
Here’s an example of how to add your GA code using the admin_footer
action hook:
add_action( 'admin_footer', 'airwolfke_google_analytics_internal' );
function airwolfke_google_analytics_internal() {
?>
<!– Google Analytics –>
<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-XXXXX-Y’, ‘auto’);
ga(‘send’, ‘pageview’, {
‘dimension1’: ‘internal’
});
</script>
<!– End Google Analytics –>
<?php
}
You could add this code to the functions.php
of your active theme. If you’re using a third-party theme, you’ll want to add this to a child theme instead of modifying the third-party theme to ensure the code is not lost if/when the theme is updated.
You could also add this code to a custom plugin, which is preferable in this case as the code is not specific to your theme.
That said, if you’re already using any decent plugin to add your Google Analytics code to the site, it should include an option to exclude the tracking code for specific users by role, making the above unnecessary.
Hope that helps!
]]>please revert as soon as possible
]]>