Title: [Plugin: Cookie Control] No Async Analytics code?
Last modified: August 20, 2016

---

# [Plugin: Cookie Control] No Async Analytics code?

 *  [cnev](https://wordpress.org/support/users/charlesneville/)
 * (@charlesneville)
 * [14 years ago](https://wordpress.org/support/topic/plugin-cookie-control-no-async-analytics-code/)
 * The current version of your plugin implements the old, synchronous, version of
   the Analytics javascript, which Google themselves have phased out from the Analytics
   interface. When will you switch to the async code? This is important because 
   currently your plugin breaks most of the advanced features in any Google Analytics
   plugin that uses _gaq.push to record events and virtual page views, used to track
   downloads, outbound clicks and conversions.
 * [http://wordpress.org/extend/plugins/cookie-control/](http://wordpress.org/extend/plugins/cookie-control/)

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

 *  [Synchro](https://wordpress.org/support/users/synchro/)
 * (@synchro)
 * [14 years ago](https://wordpress.org/support/topic/plugin-cookie-control-no-async-analytics-code/#post-2764482)
 * Indeed, there are several problems in this area.
 * Firstly, the instructions tell you to enter `ccADDAnalytics()` in the On Accept
   and On CookiesAllowed fields, yet the function provided is called `ccAddAnalytics`,
   and since JS is case-sensitive, that won’t work.
 * The instructions also tell you to create that function, however, the plugin already
   includes one (even if you leave the GA ID field empty, which I’d definitely class
   as a bug), so if you create one as instructed you’ll have a name clash.
 * I rewrote the function (and renamed it so the built-in one isn’t called) to use
   the async version:
 *     ```
       <script type="text/javascript">
       function ccAddAnalytics2() {
         "use strict";
         var _gaq = _gaq || [];
         _gaq.push(['_setAccount', 'UA-XXXXXX-XX']);
         _gaq.push(['_trackPageview']);
         (function() {
           var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
           ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
           var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
         })();
       }
       </script>
       ```
   
 * All works for me now.
 *  Plugin Author [sherred](https://wordpress.org/support/users/sherred/)
 * (@sherred)
 * [14 years ago](https://wordpress.org/support/topic/plugin-cookie-control-no-async-analytics-code/#post-2764617)
 * I plan to fix this in the next version.
    I was wanting to release it earlier 
   but haven’t had the time
 *  [MisterMetric](https://wordpress.org/support/users/netpotentialuk/)
 * (@netpotentialuk)
 * [14 years ago](https://wordpress.org/support/topic/plugin-cookie-control-no-async-analytics-code/#post-2764633)
 * Thx Synchro for spotting that I was wondering why we were getting weird GA results.
   Can you tell me about the Asynch code you wrote, it’s late, long day and tired
   so can’t work out where to put it in the cookie control file, any pointers would
   be appreciated.
 * sherred: appreciate the plugin (but not the headache re: analytics!!! 😉 update
   that code asap please. Many thanks for your work on this.
 *  [Synchro](https://wordpress.org/support/users/synchro/)
 * (@synchro)
 * [14 years ago](https://wordpress.org/support/topic/plugin-cookie-control-no-async-analytics-code/#post-2764636)
 * I didn’t put it inside the plugin at all as that would break when the plugin 
   is updated. The plugin calls whatever function name you give it, so I named it
   not to clash with its own implemntation and just included it in my own pages 
   by sticking the script in the footer.

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

The topic ‘[Plugin: Cookie Control] No Async Analytics code?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/cookie-control_ceeddc.svg)
 * [Cookie Control](https://wordpress.org/plugins/cookie-control/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-control/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-control/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-control/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-control/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-control/reviews/)

## Tags

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

 * 4 replies
 * 4 participants
 * Last reply from: [Synchro](https://wordpress.org/support/users/synchro/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/plugin-cookie-control-no-async-analytics-code/#post-2764636)
 * Status: not resolved