Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Move Google Analytics from bottom of <body> to bottom of <head> #891

Closed
wants to merge 1 commit into from

2 participants

@MarceI

Based on Google's own recommendations on placement of the analytics.js JavaScript snippet.

@Foxaii
Collaborator

Thanks but no thanks. We're using HTML5 Boilerplate's optimised Google Analytics snippet, so as long as they put it in the body, we will too.

@Foxaii Foxaii closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 30, 2013
  1. @MarceI

    Move Google Analytics from bottom of <body> to bottom of <head>

    MarceI authored
    Based on Google's own recommendations on placement of the analytics.js JavaScript snippet.
    
    https://developers.google.com/analytics/devguides/collection/analyticsjs/
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 9 deletions.
  1. +9 −9 lib/scripts.php
View
18 lib/scripts.php
@@ -52,16 +52,16 @@ function roots_jquery_local_fallback($src, $handle = null) {
add_action('wp_head', 'roots_jquery_local_fallback');
function roots_google_analytics() { ?>
-<script>
- (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'));
- ga('create','<?php echo GOOGLE_ANALYTICS_ID; ?>');ga('send','pageview');
-</script>
+ <script>
+ (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'));
+ ga('create','<?php echo GOOGLE_ANALYTICS_ID; ?>');ga('send','pageview');
+ </script>
<?php }
if (GOOGLE_ANALYTICS_ID && !current_user_can('manage_options')) {
- add_action('wp_footer', 'roots_google_analytics', 20);
+ add_action('wp_head', 'roots_google_analytics', 20);
}
Something went wrong with that request. Please try again.