http - How to post to Google Measurement protocol using Python? -


measurement protocol guide

i need example of how post using python.

something this, working.

import httplib, urllib conn = httplib.httpconnection("www.google-analytics.com") conn.request("post", "v=1&tid=ua-xxxxxx-y&cid=666&t=event&ec=game&ea=start&ev=0") response = conn.getresponse() print response.status, response.reason data = response.read() conn.close() 

you needed url:

conn.request("post", "/collect", "v=1&tid=ua-xxxxxx-y&cid=666&t=event&ec=game&ea=start&ev=0") 

or dictionary:

import httplib, urllib  params = urllib.urlencode({     'v': 1,     'tid': 'ua-xxxxxx-y',     'cid': '666',     't': 'event',     'ec': 'game',     'ea': 'start',     'ev': 0 })  connection = httplib.httpconnection('www.google-analytics.com') connection.request('post', '/collect', params) 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -