Skip to main content

A Python library for processing Google Analytics 4 data

Project description

GA4 Analytics Processor

A Python library for processing Google Analytics 4 data with built-in data transformations and channel grouping logic.

Installation

pip install ga4-analytics-processor

Quick Start

from ga4_analytics import GA4Processor
from datetime import datetime, timedelta

# Initialize processor
processor = GA4Processor(
    credentials_path="/path/to/your/credentials.json",
    property_id="your_ga4_property_id"
)

# Define date range
end_date = datetime.now().date()
start_date = end_date - timedelta(days=7)

# Fetch and process general report with default dimensions/metrics
df = processor.get_general_report(start_date, end_date)

# Or specify custom dimensions and metrics
custom_dimensions = ["date", "sessionDefaultChannelGroup", "deviceCategory"]
custom_metrics = ["sessions", "totalRevenue", "transactions"]
df_custom = processor.get_general_report(
    start_date, end_date,
    dimensions=custom_dimensions,
    metrics=custom_metrics
)

# For completely custom reports with optional processing
df_raw = processor.get_custom_report(
    start_date, end_date,
    dimensions=custom_dimensions,
    metrics=custom_metrics,
    apply_processing=False  # Get raw data without transformations
)

print(df.head())

Features

  • Easy GA4 API integration
  • Flexible dimensions and metrics - specify your own or use defaults
  • Custom report generation - with optional data processing
  • Built-in data transformations and cleaning
  • Channel grouping and campaign labeling
  • Revenue reallocation logic
  • Email campaign data integration
  • Configurable data formatting

New in v0.2.0

  • Custom dimensions and metrics in get_general_report()
  • New get_custom_report() method for full flexibility
  • Optional data processing - get raw data or processed data
  • Backward compatible - existing code continues to work

Requirements

  • Python 3.8+
  • Google Analytics Data API credentials
  • pandas, numpy, google-analytics-data

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ga4_analytics_processor-0.2.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ga4_analytics_processor-0.2.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file ga4_analytics_processor-0.2.0.tar.gz.

File metadata

  • Download URL: ga4_analytics_processor-0.2.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ga4_analytics_processor-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2b1985cdf36caf77c078300d56468b3ae20074c8b59e6736644065fa6b4d9f4a
MD5 3a5b596b08a3abc56c90b061c36b6d29
BLAKE2b-256 34fbf7c7e31325bf3dbfe006ddf4cfe2420ce8d6f5bd62d5df1ca1cb88ddc50d

See more details on using hashes here.

File details

Details for the file ga4_analytics_processor-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ga4_analytics_processor-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66c6a47e94b65736a3325c586f8c57dd9076d01c55bb519a29daa608af5e214b
MD5 2e56ff251de60a342d478284a8df7cb4
BLAKE2b-256 fbfe6b4167f9a9904877c3fb48c4b2c2062a4358142d3150eae84360f956de9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page