{"id":27779,"library":"ga4-data-import","title":"GA4 Data Import","description":"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.","status":"active","version":"0.1.66","language":"python","source_language":"en","source_url":"https://github.com/max-ostapenko/ga4_data_import/","tags":["ga4","google-analytics","data-import","analytics"],"install":[{"cmd":"pip install ga4-data-import","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Official GA4 Data API client","package":"google-analytics-data","optional":false},{"reason":"Authentication for GCP services","package":"google-auth","optional":false}],"imports":[{"note":"Incorrect submodule path, might have been guessed from older docs.","wrong":"from ga4_data_import.ga4 import GA4DataImport","symbol":"GA4DataImport","correct":"from ga4_data_import import GA4DataImport"}],"quickstart":{"code":"import os\nfrom ga4_data_import import GA4DataImport\n\ncredentials_path = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', '/path/to/service-account.json')\nclient = GA4DataImport(\n    property_id='123456789',\n    credentials_path=credentials_path\n)\nresponse = client.upload_data(\n    data_source_id='your-datasource-id',\n    dataset=[\n        {'item_id': 'SKU123', 'item_name': 'Example', 'quantity': 2}\n    ]\n)\nprint(response)","lang":"python","description":"Initializes the GA4DataImport client and uploads a small dataset."},"warnings":[{"fix":"Pass a plain numeric string, e.g., '123456789'.","message":"Property ID must be a numeric string without 'properties/' prefix. Using 'properties/123456789' will fail.","severity":"breaking","affected_versions":"all"},{"fix":"You must delete data via the GA4 UI or the Admin API before re-uploading if needed.","message":"The library does not support deletion or overwrite of existing data rows. Uploads are additive only.","severity":"gotcha","affected_versions":"all"},{"fix":"Change import to: from ga4_data_import import GA4DataImport","message":"The 'ga4_data_import.ga4' module is deprecated and will be removed. Use 'ga4_data_import.GA4DataImport' directly.","severity":"deprecated","affected_versions":">=0.1.50"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Upgrade to latest version: pip install --upgrade ga4-data-import and use 'property_id' as documented.","cause":"Using an older version of the library where the constructor argument was named 'property_id' differently (e.g., 'view_id' for universal analytics).","error":"TypeError: __init__() got an unexpected keyword argument 'property_id'"},{"fix":"Ensure service account has the 'roles/analytics.edit' role and that the data source ID is correct (found in GA4 Admin > Data Imports).","cause":"Service account lacks the 'GA4 Data Import' role or the data source ID does not exist.","error":"google.api_core.exceptions.PermissionDenied: 403 The caller does not have permission"},{"fix":"Refer to GA4 documentation for correct naming: e.g., 'customItem:my_param' (snake_case) for item-scoped dimensions.","cause":"Using custom dimension/metric names incorrectly. GA4 expects camelCase or snake_case depending on the scope.","error":"ValueError: Dimension 'customItem:myParam' is not valid."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}