Tracking to Google Analytics from python

最后都变了- 提交于 2019-12-10 10:47:50

问题


I'm trying to track GA events from python backend for ecommerce analysis. The way it's written in the official documentation, that is sending a post request, nothing shows up, I still have zero visitors in the dashboard, but google replies with 200 and a GIF.

In this example I'm sending a pageview, which obviously makes no sense doing from the backend, but it's simple enough for debugging.

This is my code:

import requests

payload = {
    'v': 1,
    'tid': 'UA-XXXXXX-Y',
    'cid': 555,
    't': 'pageview',
    'dp': '/home',
}
print 'sending to GA...'
r = requests.post("http://www.google-analytics.com/collect", data=payload)
if r.ok:
    print 'ok'
else:
    print ':('

I have disabled all filters in GA.


回答1:


I think it is an authentication problem try using postman and try your post url works or not




回答2:


It seems that it was filters anyway, mysteriously started working properly :(



来源:https://stackoverflow.com/questions/28987973/tracking-to-google-analytics-from-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!