Search code examples
google-analyticsuseriduniversal-analytics

Google Analytics universal is not tracking page views nor events when user-id is set


Recently we update our system to work with google analytics universal. We migrated the property to use universal analytics, and a few days later, we made the code changes according to the guide: https://developers.google.com/analytics/devguides/collection/upgrade/guide

We made the change to also use the User-ID functionality. Every event or page view is tracked normally, but the goals completions (which are in the end when a user reaches a specific page).

We introduced the user-id on the midday of the August 6th, and as you can see, the day after the goals were 0 (although because of our database, I can tell was about 25). Day after (8th), the goals (as said before, pageviews with the user-id set) were tracked normally again. Day 9th only a few (and were much more). From that day on, not at all are tracked.

analytics goals

In the beginning I believed that it takes longer to analytics to put the data together because of the user-id, but it seems to me very strange.

The code i am using is:

    <!-- Google Analytics Universal-->
<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', 'UA-xxxxxxx-y', {
        'cookieDomain': 'xxxxxxx.xx',
        'siteSpeedSampleRate': 25
    });


    {% if userId is set %}
        ga('set', '&uid', userId);
    {% endif %}


     ga('send', 'pageview');

Everything pretty straightforward, and I am also using the google analytics debug tool to check if all the data is sent, and yes, it's sent. In addition to that, if I reach a page that tracks a goal myself, I can see my session in the real time, so data is sent to analytics.

That's why I am thinking that I am missing some configuration from the google analytics side. I already created a user-id view and the data there contains the same information, but only from 6th august, when user-id functionality was started to be used.

Anyone has an idea or has the same trouble?

Thanks!


Solution

  • If you're using a debug tool and have verified that the user ID is in fact being sent as part of the hit to Google Analytics, then that means you're doing everything correctly on your end.

    I copied your exact code, replaced the userId variable with the string 'foobar', and I was also able to verify that the hit was sent correctly, including the string 'foobar'. Here's what it looked like:

    http://www.google-analytics.com/collect?
      v=1&
      _v=j25&
      a=1335799492&
      t=pageview&
      _s=1&
      dl=http%3A%2F%2Flocalhost%2Ftest.html&
      ul=en-us&
      de=UTF-8&
      sd=24-bit&
      sr=2560x1440&
      vp=1605x611&
      je=1&
      fl=14.0%20r0&
      _u=cACAAET~&
      cid=2022234602.1393626891&
      uid=foobar&
      tid=UA-XXXX-Y&
      z=304825725
    

    If the data is not properly showing up in your reports, and you're sure that everything is set up correctly for your userId-enabled view, then it could be a bug, and if so, the best thing to do is simply report it to Google.

    The best place to report the bug is here:
    https://code.google.com/p/analytics-issues/issues/entry

    UPDATE (08/26/2014)

    It looks like there's already a bug entered for this issue. You can star it here to be notified of fixes/updates: https://code.google.com/p/analytics-issues/issues/detail?id=477