Registry / gcp / ga4-data-import

ga4-data-import

JSON →
library0.1.66pypypi✓ verified 81d ago

A Python library for importing data into Google Analytics 4 (GA4) via the Data API. Version 0.1.66 supports batch data uploads for user, item, and event-scoped dimensions and metrics. It uses the google-analytics-data library under the hood. Active development with frequent releases.

pip install ga4-data-import
INSTALL
IMPORT
SIG · GA4-DATA-IMPORT
G
ga4-data-import
gcppythonv0.1.66
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

add_bucket_read_access
from ga4_data_import import add_bucket_read_access
from ga4_data_import import GA4DataImport
add_server_pub_key
from ga4_data_import import add_server_pub_key
from ga4_data_import import GA4DataImport
create_bucket
from ga4_data_import import create_bucket
from ga4_data_import import GA4DataImport

Initializes the GA4DataImport client and uploads a small dataset.

import os from ga4_data_import import GA4DataImport credentials_path = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', '/path/to/service-account.json') client = GA4DataImport( property_id='123456789', credentials_path=credentials_path ) response = client.upload_data( data_source_id='your-datasource-id', dataset=[ {'item_id': 'SKU123', 'item_name': 'Example', 'quantity': 2} ] ) print(response)
Debug
Known issues
breakingProperty ID must be a numeric string without 'properties/' prefix. Using 'properties/123456789' will fail.
fix
Pass a plain numeric string, e.g., '123456789'.
affects: all
gotchaThe library does not support deletion or overwrite of existing data rows. Uploads are additive only.
fix
You must delete data via the GA4 UI or the Admin API before re-uploading if needed.
affects: all
deprecatedThe 'ga4_data_import.ga4' module is deprecated and will be removed. Use 'ga4_data_import.GA4DataImport' directly.
fix
Change import to: from ga4_data_import import GA4DataImport
affects: >=0.1.50
Upgrade
Version history
0.1.66latest on PyPI · released Feb 14, 2024
Audit
Dependencies
google-analytics-datarequiredOfficial GA4 Data API client
google-authrequiredAuthentication for GCP services
Agent activity
34 hits · last 30 days
node
28
OpenAI (training)
1
Resources
ga4-data-import — pip install ga4-data-import · libregistry