1

In brief: I'm logging Google Analytics hits from backend application logic (it's a slack app, so client-side logging isn't possible). I'm fairly confident the hits are being correctly sent (more details on that below), and they appear as expected in the realtime view. They do not appear in the non-realtime view at all, even after days of steady generation.

Obviously I'm doing something wrong, but I'm at a loss as to what it could be. I've tried to search for similar problems and solutions, and am pretty sure none of the common issues are my problem.

Details: I'm generating hit from python, but have instrumented the code to log the URL encoded parameters that I'm sending, for example:

v=1&an=faw&uid=8763edbc96704b6e8fb8a19cffaf6211&tid=UA-<MYTRACKERID>-1&t=screenview&cd=screenname

There are three reasons I'm pretty confident that that part is correct:

  1. When I enter the same parameters into the GA Hit Builder tool it calls them valid, and if I use the Hit Builder to then post the hit to Google Analytics that event behaves exactly like the ones my app sends.
  2. When I alter my code to send traffic to google's debug endpoint (as described here) the response indicates that the hit was valid.
  3. They show up in the realtime view. Yes, I know that it takes a day or two for things to appear in the non-realtime view. It's been well over a week at this point, and there's still nothing. I've even put together a simple test driver to inject hits similar to those my app sends every 5 minutes or so, so I know there's a steady stream of hits -- they reliably show up in the realtime view (only): realtime view regular (non-realtime) view

Interestingly, and further confirming my suspicion that the hits are being sent correctly, the non-realtime view does show "active users" from my drip of test hits (see the right-hand side of the image above). Inexplicably, though, those active sessions never translate into historical sessions.

Since it seems like hits are being sent correctly, I wonder if there's something about my view configuration - I've seen other similar problems I was able to google resolved by removing filters, etc. Here's what I've checked there:

  • The "bot filtering" checkbox ('Exclude all hits from known bots and spiders') is not checked.
  • There are no active filters (the table 'filter' tab of my view has no data)

I'm sure this is user error in some manner, but I'm really stumped about what it could be. Any suggestions about things to try are greatly appreciated.


For completeness' sake, here's the python code I'm using to generate the test dribble of hits - this runs every 5 minutes, and is part of the traffic seen above in the screencap of the realtime view. Only the tracker ID has been changed.

# simulate GA hits like those we send from the app, but without using
#   the Tracker class

# here's an example of a hit that we send that:
#  1) shows up in the realtime view
#  2) never shows up in the report
#

import httplib2, urllib.parse

hit = {
    'v': 1,
    'an': 'faw',
    'uid': '5309',
    'tid': 'UA-<MYTRACKERID>-1',
    't': 'screenview',
    'cd': 'manualTest'
}

conn = httplib2.Http()
(resp_headers, content) = conn.request(
    'https://www.google-analytics.com/collect',
    'POST', urllib.parse.urlencode(hit)
)
#print("sending GA hit like: {}".
#      format(urllib.parse.urlencode(hit)))

if int(resp_headers['status']) != 200:
    print("ERROR - got {} sending stats: {}".format(resp_headers['status'],
                                                    content)
    )
  • We primarily only deal with websites here, so it might be best to ask this over at Stack Overflow. Comment back if you'd like to me migrate it there for you. – dan Jan 10 at 5:43
  • Thanks Dan - I was unsure of the best place on SE for this. I avoided SO at first because I suspect this is more of a google analytics config/usage question than a development question, but if you think it'll be a better fit there, then by all means please do migrate it. Thanks! – jrheling Jan 10 at 12:41
  • Update: The details in [en.advertisercommunity.com/t5/Google-Analytics-Code/… makes me think this might result from me using 'uid' instead of 'cid'. I have modified one of the running tests, so should have some results in ~24h; I'll update this accordingly. – jrheling Jan 10 at 14:40
1

The link referenced in my "update" comment on the original question does seem to contain the answer. (I'm posting an answer separately so this is hopefully easier for the next person who stumbles into this.)

Simply changing the "uid" parameter to be "cid" instead causes hits to appear as expected in the non-realtime views. The docs are not very clear on this matter. (There is presumably some other undocumented condition required for the uid parameter to suffice.)

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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