How do I track a PYPI project using Google Analytics?
2 answers
It is best to use Measurement Log to send clicks. If you can send an HTTP request using the requests module:
pip install requests
You can use something similar to the example below with your own tracking ID and parameters.
import requests
payload = {'v': '1', # Version.
'tid': 'UA-XXXXX-1', # Tracking ID / Property ID.
'cid': '123456', # Anonymous Client ID.
'dh': 'www.example.com', # Document hostname.
'dp': 'home', # Page.
't': 'pageview' # Hit Type.
}
requests.post('http://www.google-analytics.com/collect', payload)
Just make sure the code runs during any given event that you want to monitor.
+1
source to share