在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):debrouwere/google-analytics开源软件地址(OpenSource Url):https://github.com/debrouwere/google-analytics开源编程语言(OpenSource Language):Python 99.1%开源软件介绍(OpenSource Introduction):Google Analytics for Python and the command-line
This package is built on top of Google's own API client for Python. QuickstartFirst, install the package using pip
Then, create a new project in the Google Developers Console, enable the Analytics API under "APIs & auth > APIs" and generate credentials for an installed application under "APIs & auth > Credentials". Keep this page open. For more detail, look at the wiki page on authentication. After that, executing your first query is as easy as import googleanalytics as ga
accounts = ga.authenticate()
profile = accounts[0].webproperties[0].profile
pageviews = profile.core.query.metrics('pageviews').range('yesterday').value
print(pageviews) Or on the command-line, that'd be: googleanalytics --identity <identity> --account <account> --webproperty <webproperty> \
query pageviews --start yesterday The account, webproperty and profile determine what data you'll be querying. Learn more about profiles and querying on the Querying wiki page, or alternatively look at the Common Queries page for lots of examples. Read more about how to work with the resulting data in Working With Reports. On The Command-Line has more details about the command-line application. The example above will authorize the app and authenticate you interactively. It is also possible to pass credentials as arguments in Python, using environment variables or from your operating system's keychain. Authentication is treated in much more depth on the authentication wiki page. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论