Title: Google Analytics -plugin with W3Totalcache
Last modified: May 31, 2018

---

# Google Analytics -plugin with W3Totalcache

 *  Resolved [temposaur](https://wordpress.org/support/users/temposaur/)
 * (@temposaur)
 * [8 years ago](https://wordpress.org/support/topic/google-analytics-plugin-with-w3totalcache/)
 * Google Analytics -plugin won’t work with w3totalcache out of the box.
 * But with this small modification, it will:
 * Replace file content from view/ga_googleanalytics_loader.php
    with this:
 *     ```
       <?php
       $js = "
       <script>
           jQuery(document).ready(function () {
       		jQuery.post('".esc_attr( $ajaxurl ) ."', {action: 'googleanalytics_get_script'}, function(response) {
       			var F = new Function ( response );
       			return( F() );
       		});
           });
       </script>";
   
       wp_add_inline_script("google_analytics", $js, 'after');
       ```
   
 * It will now allow js-script to be minified and placed in right position when 
   using w3totalcache.

The topic ‘Google Analytics -plugin with W3Totalcache’ is closed to new replies.

 * ![](https://ps.w.org/googleanalytics/assets/icon-256x256.jpg?rev=2624799)
 * [ShareThis Dashboard for Google Analytics](https://wordpress.org/plugins/googleanalytics/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/googleanalytics/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/googleanalytics/)
 * [Active Topics](https://wordpress.org/support/plugin/googleanalytics/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/googleanalytics/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/googleanalytics/reviews/)

## Tags

 * [w3totalcache](https://wordpress.org/support/topic-tag/w3totalcache/)

 * 0 replies
 * 1 participant
 * Last reply from: [temposaur](https://wordpress.org/support/users/temposaur/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/google-analytics-plugin-with-w3totalcache/)
 * Status: resolved