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:
- 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.
- When I alter my code to send traffic to google's debug endpoint (as described here) the response indicates that the hit was valid.
- 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):
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)
)