30

I'm setting up with the new Google Analytics tracking code.

<script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

      ga('create', 'MYUACODE', 'MYDOMAIN');
      ga('send', 'pageview', {
          'page': '/setup',
          'title': 'Setup Page'
        });

    </script>

I've got this inside my HEAD tag as Google tell you to do Obviously MYUACODE and MYDOMAIN are the real variables in my page :)

However when I run this using Google Chrome and I turn on the Google Analytics Debug extension, I get the following message:

Registered new plugin: "linker"       analytics_debug.js:5
Creating new tracker: t0              analytics_debug.js:5
New visitor. Generating new clientId  analytics_debug.js:5
Storage not available. Aborting hit.  analytics_debug.js:5

It seems to fire up correctly and starts setting up the items, but then it says Storage not available and it seems nothing ever gets to Google.

Now if I remove all this code and go back to the original Google Tracking code, it works fine, I just can't seem to get this new style to fire correctly.

Any thoughts? Help? Thanks in advance

0

6 Answers 6

37

I had the same error message. It seems to be related to not being able to set the cookie correctly. In my case, it happened when I was testing off localhost and I hadn't set my cookieDomain to none.

You may want to try something like the following and see if it works. I'm not sure if the method of passing your domain that you have works.

ga('create', 'MYUACODE', {
  'cookieDomain': 'none'
});
2
  • 1
    I'm having the same problem. Only the difference is I'm not on local i.e. I'm on www.foobar.com and mentioning the same domain in the code still does not work. Commented Feb 24, 2015 at 13:07
  • i needed to add storage: none to make this solution work and I also provided clientId hash manually as written here worked also on GTM implementation developers.google.com/analytics/devguides/collection/… Commented Oct 20, 2020 at 12:47
13

Google Analytics used to generate the tracking code with the hostname hard coded in the create method, which could cause this error when testing on a different hostname. Now when GA generates the tracking code it uses

ga('create', 'UA-XXXXXXXX-X', 'auto');

which automatically determines the cookieDomain value. Changing the hardcoded hostname to 'auto' in this method call has fixed this issue for me on several sites that had the old tracking code generated.

5

Actually, most of the options presented will work. However, they all should be applied in different scenarios. Please refer to GoogleA's Domains & Cookies - Web Tracking (analytics.js) for the full list.

I handled my client's situation a bit differently to deal with language variants, one of which was on a separate domain. Below you'll see the domain followed by the tracker creation call:

  1. en.client.en, ga('create', 'UA-XXXXXXXX-X', 'client.en');
  2. fr.client.com, ga('create', 'UA-XXXXXXXX-X', 'client.com');
  3. de.client.com, ga('create', 'UA-XXXXXXXX-X', 'client.com');
  4. xx.client.com, ga('create', 'UA-XXXXXXXX-X', 'client.com');

The reason I did not use

ga('create', 'UA-XXXXXXXX-X', 'auto')

or 'none' for the domain parameter was because that configuration is unlikely to track subdomains. My client will probably want view conversions by country / language. Thus, the account will have the grouped view (configured above), as well as individual views filtered by subdomain (country / language). In the Google documentation, it clearly states under Automatic Cookie Domain Configuration:

Analytics.js will fail to write a cookie on co.uk but will succeed on example.co.uk. Since a cookie was succesfully written on a higher level domain, www.example.co.uk will be skipped.

and under Setting cookies on localhost (where cookieDomain is set to 'none'):

Note: This will set a host only cookie domain. The cookie will not propgate to any subdomains. However, Internet Explorer does not follow this pattern.

Hope this helps.

1

Playing with 'MYDOMAIN' resolved the problem for me

ga('create', 'MYUACODE', 'MYDOMAIN');

i removed 'MYDOMAIN' at all and leaved it like

ga('create', 'MYUACODE');

restarted the page, then added , 'MYDOMAIN'n again and this worked

The second time i faced with the problem it solved the problem to change 'MYDOMAIN' to the domain i was loading the page from (from production domain to my hosting domain)

1

Another option is to add a domain to your host file and then use that instead of localhost. Mine looks like:

127.0.0.1 localhost mytest.com

Use mytest.com instead of localhost and you will be able to check your info and you won't have to add any options to the ga create method call.

0

I think the issue was with another extension in chrome. Using an empty profile (--user-data-dir=/tmp/foo) resolved the problem for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.