Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Google Analytics, move to Soil #1381

Closed
retlehs opened this issue Mar 12, 2015 · 1 comment
Closed

Remove Google Analytics, move to Soil #1381

retlehs opened this issue Mar 12, 2015 · 1 comment

Comments

@retlehs
Copy link
Member

retlehs commented Mar 12, 2015

it's time to move the GA snippet from html5 boilerplate to soil

lib/config.php

if (!defined('GOOGLE_ANALYTICS_ID')) {
  // Format: UA-XXXXX-Y (Note: Universal Analytics only)
  define('GOOGLE_ANALYTICS_ID', '');
}

lib/assets.php

/**
 * Google Analytics snippet from HTML5 Boilerplate
 *
 * Cookie domain is 'auto' configured. See: http://goo.gl/VUCHKM
 */
function google_analytics() {
  ?>
  <script>
    <?php if (WP_ENV === 'production' && !current_user_can('manage_options')) : ?>
      (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 : ?>
      function ga() {
        if (window.console) {
          console.log('Google Analytics: ' + [].slice.call(arguments));
        }
      }
    <?php endif; ?>
    ga('create','<?= GOOGLE_ANALYTICS_ID; ?>','auto');ga('send','pageview');
  </script>
  <?php
}
if (GOOGLE_ANALYTICS_ID) {
  add_action('wp_footer', __NAMESPACE__ . '\\google_analytics', 20);
}
@retlehs
Copy link
Member Author

retlehs commented Mar 13, 2015

closed by #1382 and roots/soil#56

@retlehs retlehs closed this as completed Mar 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant