How to trigger Google Analytics events from Python?

后端 未结 6 1286
礼貌的吻别
礼貌的吻别 2020-12-15 05:06

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 Pyth

6条回答
  •  感动是毒
    2020-12-15 05:14

    In the present you can use Google Analytics Measurement Protocol. There are some python libraries to send events, for example xoxzo.galib:

    client = HitClient('UA-12345678-1')
    client.send_hit('event', event_category='auth', event_action='signup')
    

    Or google-measurement-protocol or you can write requests yourself with python-requests by this guide.

提交回复
热议问题