Socket
Socket
Sign inDemoInstall

pygoogleanalytics

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pygoogleanalytics

Wrapper for Google Analytics API python call


Maintainers
1

PyGoogleAnalytics

Wrapper for Google Analytics API python calls

Setup

First and foremost you need a google analytics api service account. Details are available here see https://developers.google.com/analytics/devguides/reporting/core/v4/ for more details Instructions are available here https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-py

    $ pip install git+ssh://git@github.com/ademilly/pygoogleanalytics.git

Usage

import pygoogleanalytics

# Inputs for standard google analytics reporting api
api = pygoogleanalytics.APICaller(
    ['https://www.googleapis.com/auth/analytics.readonly'],
    ('https://analyticsreporting.googleapis.com/$discovery/rest'),
    PATH_TO_P12_SECRET_FILE,
    SERVICE_ACCOUNT_ADDRESS
)

# prepare a dimensionFilterClauses with a 'and' operator
request_filter = pygoogleanalytics.RequestFilter('and').add_filter(
    {
        "dimensionName": "some_dimension",
        "operator": "some_operation",
        "expressions": "some_expression"
    }
).add_filter(
    {
        "dimensionName": "some_dimension",
        "operator": "some_operation",
        "expressions": "some_expression"
    }
)

some_kpi = pygoogleanalytics.Requester(api).build_request().for_view(
    'some_view_id'
).between(
    'some_start_date', 'some_end_date'
).for_variables(
    ['var1', 'var2', ...]
).with_filter_clause(request_filter).run_request().get_value('metrics')

print some_kpi

output:

    ['some_value', ...]

Keywords

FAQs


Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc