Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger Google Analytics events from Python?

Tags:

I'm developing a site that has a REST API and I'd like to track the API usage using Google Analytics events. Is there a straightforward way to trigger GA events from Python that doesn't involve loading up an entire webbrowser component just to send a javascript request?

like image 695
Soviut Avatar asked Jan 11 '10 02:01

Soviut


People also ask

Does Google Analytics have an API?

The Google Analytics Reporting API v4 provides programmatic methods to access report data in Google Analytics (Universal Analytics properties only). With the Google Analytics Reporting API, you can: Build custom dashboards to display Google Analytics data. Automate complex reporting tasks to save time.


2 Answers

This project called PyGA is much better. Unlike "Google-Analytics for Mobile" project on github it is well documentated and has rich API.

like image 169
Daniil Ryzhkov Avatar answered Oct 16 '22 23:10

Daniil Ryzhkov


There is an open source implementation of Google-Analytics for Mobile in python available here: http://github.com/b1tr0t/Google-Analytics-for-Mobile--python-

You can probably integrate this into your own setup by importing 'track_page_view' and providing it with the appropriate WSGI request environment.

like image 41
jbochi Avatar answered Oct 16 '22 23:10

jbochi