
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
|Build Status|
google-analytics
takes the pain out of working with the Google
Analytics reporting APIs. It supports both the Core and the Real Time
API. It is written in Python but there's also a full-featured
command-line interface.
server applications <https://github.com/debrouwere/google-analytics/blob/master/examples/server.py>
__.
We can also save your credentials in the operating system's keychain
if you want to.easy-to-read and easy-to-write YAML files <https://github.com/debrouwere/google-analytics/blob/master/examples/query.yml>
__.
Reports in Python work better too: iterate through the entire report
or column-per-column.Pandas <http://pandas.pydata.org/>
__ data frames – so you can
analyze the data in anything from Excel to R.This package is built on top of Google's own API client for Python <https://developers.google.com/api-client-library/python/start/installation>
__.
First, install the package using
pip <https://pip.pypa.io/en/latest/>
__
pip install googleanalytics
pip3 install googleanalytics
Then, create a new project in the Google Developers Console <https://console.developers.google.com>
, 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 <https://github.com/debrouwere/google-analytics/wiki/Authentication>
.
After that, executing your first query is as easy as
.. code:: python
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:
.. code:: shell
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 <https://github.com/debrouwere/google-analytics/wiki/Querying>
__
wiki page, or alternatively look at the Common Queries <https://github.com/debrouwere/google-analytics/wiki/Common-Queries>
__
page for lots of examples. Read more about how to work with the
resulting data in Working With Reports <https://github.com/debrouwere/google-analytics/wiki/Working-With-Reports>
.
On The Command-Line <https://github.com/debrouwere/google-analytics/wiki/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 <https://github.com/debrouwere/google-analytics/wiki/Authentication>
__.
.. |Build Status| image:: https://travis-ci.org/debrouwere/google-analytics.svg :target: https://travis-ci.org/debrouwere/google-analytics
FAQs
A wrapper for the Google Analytics API.
We found that googleanalytics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.