fusetools.marketing_tools.GoogleAnalytics

class fusetools.marketing_tools.GoogleAnalytics[source]

Bases: object

Functions for interacting with Google Analytics.

../_images/googleanalytics1.png

Methods

authorize_credentials

Initializes an Analytics Reporting API V4 service object.

ga_pull_metrics

Generates a Google Analytics report.

static authorize_credentials(filename)[source]

Initializes an Analytics Reporting API V4 service object.

Parameters

filename – Filepath to authentication JSON token.

Returns

An authorized Analytics Reporting API V4 service object.

classmethod ga_pull_metrics(creds, view_id, start_date, end_date, metrics, dimensions=False, filter_dimensions=False, filter_operators=False, filter_expressions=False, filter_excludes=False)[source]

Generates a Google Analytics report.

Parameters
  • creds – Authentication object.

  • view_id – Id for organization’s Google Analytics account.

  • start_date – Reporting start date.

  • end_date – Reporting end date.

  • metrics – List of KPIs to compute. Docs: https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/.

  • dimensions – List of Dimensions to aggregate results by. Docs: https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/.

  • filter_dimensions – List of Dimensions to filter results by.

  • filter_operators – List of arithmetical operators to constraint dimensions by.

  • filter_expressions – List of expressions to constraint dimensions by.

  • filter_excludes – Whether or not use dimension filter to exclude results.

Returns

JSON response with report results.