Title: Don&#8217;t include google analytics
Last modified: October 15, 2018

---

# Don’t include google analytics

 *  Resolved [George](https://wordpress.org/support/users/geoogz/)
 * (@geoogz)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/)
 * Hi guys,
 * Is it possible to check the “Also aggregate inline JS?” without including the
   google analytics code and some tracking events? Coz I’m having trouble on optimizing
   my page. Please see attached URL ( [http://mockupr.com/mu/uzvl9825/page-optimization](http://mockupr.com/mu/uzvl9825/page-optimization)).
 * The real deal is Page Speed still “UNAVAILABLE”. Maybe if we exclude the analytics
   in the js it will lessen the file size of generated js by autoptimize or not?
 * I hope someone can help me 😀
 * Note:
    - I checked “Also aggregate inline JS?” because of deferring the jquery.js and
      other js files and also the aggregate one.
    - Revolution slider and Lazy load is active

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/#post-10780450)
 * you can exclude any inline JS by adding a (unique) keyword from it to AO’s comma-
   separated JS optimization exclusion list [@geoogz](https://wordpress.org/support/users/geoogz/),
   have a look at [the AO FAQ](https://wordpress.org/plugins/autoptimize/#faq) for
   more info on how to exclude.
 * hope this helps,
    frank
 *  Thread Starter [George](https://wordpress.org/support/users/geoogz/)
 * (@geoogz)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/#post-10780511)
 *     ```
       <!-- Global site tag (gtag.js) - Google Analytics -->
       <script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
       <script>
         window.dataLayer = window.dataLayer || [];
         function gtag(){dataLayer.push(arguments);}
         gtag('js', new Date());
   
         gtag('config', 'GA_TRACKING_ID');
       </script>
       ```
   
 * Like this one sir frank. It is possible to exclude it in aggregating js. I want
   to stay the code at the top of the head, not in the generated autoptimize file.
 * I excluded it but nothing change ‘seal.js,gtag.js,google-analytics.js’
    -  This reply was modified 7 years, 7 months ago by [George](https://wordpress.org/support/users/geoogz/).
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/#post-10780531)
 * try adding your GA tracking ID (or `gtag`), that should work 🙂
 *  Thread Starter [George](https://wordpress.org/support/users/geoogz/)
 * (@geoogz)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/#post-10780591)
 * Thank you so much (Y)
 * How about javascript like this one sir
 *     ```
       <script>
               document.addEventListener("DOMContentLoaded", function(event) {
                   var animate = document.getElementsByClassName("animate"),
                       len = animate !== null ? animate.length : 0,
                       i = 0;
   
                   for (i; i < len; i++) {
                       animate[i].className += " active";
                   }
               });
           </script>
       ```
   
    -  This reply was modified 7 years, 7 months ago by [George](https://wordpress.org/support/users/geoogz/).
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/#post-10780684)
 * for that I would try with `animate[i].className` 🙂
 *  Thread Starter [George](https://wordpress.org/support/users/geoogz/)
 * (@geoogz)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/#post-10780704)
 * Thanks a lot, sir!
 * I’m not familiar in javascript because it’s easy to use the jquery. But with 
   your solution I think I need to target always the “function script”, is that 
   right sir?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/#post-10780715)
 * > Thanks a lot, sir!
 * Please do call me Frank 🙂
 * > I’m not familiar in javascript because it’s easy to use the jquery. But with
   > your solution I think I need to target always the “function script”, is that
   > right
 * to exclude inline JS from being aggregated you mean? sometimes the function name
   can indeed be used, unless if it’s not unique enough.
 *  Thread Starter [George](https://wordpress.org/support/users/geoogz/)
 * (@geoogz)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/#post-10783327)
 * > Please do call me Frank 🙂
 * okay Frank 😀
 * Thank you again.
    Mark as fixed

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Don’t include google analytics’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [George](https://wordpress.org/support/users/geoogz/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/dont-include-google-analytics/#post-10783327)
 * Status: resolved