Skip to content

Commit

Permalink
Always load GA snippet when not in production
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t committed Aug 7, 2014
1 parent dc0e838 commit dd7635c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ function roots_jquery_local_fallback($src, $handle = null) {
*/
function roots_google_analytics() { ?>
<script>
<?php if(WP_ENV==='production') :?>
<?php if (WP_ENV === 'production') : ?>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
<?php else: ?>
<?php else : ?>
function ga() {
console.log("GoogleAnalytics: " + [].slice.call(arguments));
console.log('GoogleAnalytics: ' + [].slice.call(arguments));
}
<?php endif; ?>
ga('create','<?php echo GOOGLE_ANALYTICS_ID; ?>','auto');ga('send','pageview');
</script>

<?php }
if (GOOGLE_ANALYTICS_ID && !current_user_can('manage_options')) {
if (GOOGLE_ANALYTICS_ID && (WP_ENV !== 'production' || !current_user_can('manage_options'))) {
add_action('wp_footer', 'roots_google_analytics', 20);
}

0 comments on commit dd7635c

Please sign in to comment.