3

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
  • 1
    put your string together. then dump it in a web browser it can be tested using a HTTP get its easer. Data should show up in the real-time reports. remember it takes 24 hours for data to show up in standard reports. also if this is a new Google analytics account it can take up to 48 hours for data to start showing up anywhere. Commented Mar 11, 2015 at 14:58

2 Answers 2

4

Had the same problem, requests from python did not appear, postman worked. Solved it by removing the checkmark in google analytics under Settings > View > View Settings > Bot Filtering: Exclude all hits from known bots and spiders.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.