Support » Plugin: Cookie Control » [Plugin: Cookie Control] No Async Analytics code?

  • cnev


    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

    All works for me now.

    Plugin Author sherred


    I plan to fix this in the next version.
    I was wanting to release it earlier but haven’t had the time

    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.

    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.