{"id":15018820,"url":"https://github.com/vincecabs/gaunit","last_synced_at":"2026-01-16T12:33:06.031Z","repository":{"id":47618338,"uuid":"247505064","full_name":"VinceCabs/GAUnit","owner":"VinceCabs","description":"GAUnit is a Python library for testing Google Analytics implementations within CI pipelines.","archived":false,"fork":false,"pushed_at":"2023-12-13T07:32:49.000Z","size":626,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-09T17:13:55.066Z","etag":null,"topics":["continuous-integration","google-analytics","pipelines","python3","robotframework","selenium"],"latest_commit_sha":null,"homepage":"https://gaunit.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VinceCabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-15T16:26:44.000Z","updated_at":"2023-01-10T16:29:43.000Z","dependencies_parsed_at":"2023-12-13T09:02:02.161Z","dependency_job_id":"b00a2ea1-3b12-4192-810f-87c605ada6ff","html_url":"https://github.com/VinceCabs/GAUnit","commit_stats":{"total_commits":166,"total_committers":2,"mean_commits":83.0,"dds":0.04216867469879515,"last_synced_commit":"16d979fda5a1aa6a0815788099b1e9341531baca"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VinceCabs%2FGAUnit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VinceCabs%2FGAUnit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VinceCabs%2FGAUnit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VinceCabs%2FGAUnit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VinceCabs","download_url":"https://codeload.github.com/VinceCabs/GAUnit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128742,"owners_count":20888234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["continuous-integration","google-analytics","pipelines","python3","robotframework","selenium"],"created_at":"2024-09-24T19:52:30.167Z","updated_at":"2026-01-16T12:33:06.015Z","avatar_url":"https://github.com/VinceCabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GAUnit\r\n\r\n[![Build Status](https://travis-ci.org/VinceCabs/GAUnit.svg?branch=master)](https://travis-ci.org/VinceCabs/GAUnit)\r\n[![Documentation Status](https://readthedocs.org/projects/gaunit/badge/?version=latest)](https://gaunit.readthedocs.io/en/latest/?badge=latest)\r\n\r\nGAUnit is a Python library used for Google Analytics implementations testing.\r\n\r\nIt is designed to be used within your pipelines in various environments such as traditional websites or Single Page Applications.\r\n\r\nGAUnit is compatible with [GA4](https://developers.google.com/analytics/devguides/collection/ga4).\r\n\r\n## Features\r\n\r\n- Automate tests for Google Analytics implementations\r\n- Write tracking plans with Python dictionaries, JSON files or Google Sheets\r\n- Check HAR files against a tracking plan\r\n- Extract GA events from HAR files\r\n- Use Python or command line\r\n\r\n## Installation\r\n\r\nYou will need [Python 3.7+](https://www.python.org/downloads/) installed.\r\n\r\nUse pip:\r\n\r\n```sh\r\npip install gaunit\r\n```\r\n\r\n## Usage\r\n\r\nLet's say you have a new video player on your product page and you want\r\nto check that the right Google Analytics event is sent when the user clicks on \"Play\":\r\n\r\n```python\r\nexpected_events = [\r\n    {\r\n        \"t\": \"pageview\",\r\n        \"dp\": \"my_product_page_name\"\r\n    },\r\n    {\r\n        \"t\": \"event\",\r\n        \"ec\": \"Video\",\r\n        \"ea\": \"Play\"\r\n    }\r\n]\r\n```\r\n\r\n### Run an automated test with Python\r\n\r\nRun a selenium test case, export har and check it against your expected _tracking plan_:\r\n\r\n```python\r\nimport gaunit\r\n\r\n# Run your Selenium test here and export har\r\n# (see Documentation or examples for more details)\r\n# ...\r\n\r\n# create your tracking plan from dict, JSON files or Google Sheets\r\ntracking_plan = gaunit.TrackingPlan.from_events(\"my_test_case\", expected_events)\r\n# check GA events\r\nr = gaunit.check_har(\"my_test_case\", tracking_plan, har_path=\"my_test_case.har\")\r\nprint(r.was_successful())\r\n# True\r\n# Congrats! both events (pageview and click) were fired.\r\n```\r\n\r\n### Or manually check HAR files with command line\r\n\r\nAlternatively to automatic tests, you can manually browse your website, export a\r\nHAR file and check it through command line:\r\n\r\n```sh\r\n$ ga check test_case.har my_test_case  # passed\r\nevents in tracking plan: 3\r\n--------------------------------------------------------------------------------\r\nGA events found: total:4 / ok:3 / missing:0\r\n✔ OK: all expected events found\r\n\r\n$ ga check test_case.har my_test_case  # failed\r\nevents in tracking plan: 3\r\n================================================================================\r\n{'t': 'event', 'ec': 'Video', 'ea': 'Play'}\r\n                                                                     ... missing\r\n--------------------------------------------------------------------------------\r\nGA events found: total:11 / ok:1 / missing:2\r\n❌ FAILED: events missing\r\n```\r\n\r\n### Robot Framework\r\n\r\nIf you want to use RobotFramework, check [GAUnit Library for Robot Framework](https://github.com/VinceCabs/robotframework-gaunitlibrary)\r\n\r\n## Documentation\r\n\r\n[Getting Started](https://gaunit.readthedocs.io/en/latest/getting_started.html).\r\n\r\nFull documentation is available [here](https://gaunit.readthedocs.io/).\r\n\r\n## Why GAUnit?\r\n\r\nTesting your Google Analytics implementation is often time consuming and, let's say it, sometimes very boring!\r\n\r\nBut most of all, if your tracking is not reliable as your application evolves, your reportings won't be either. People in your company will loose confidence in your reportings when they have to take important business decisions. You will provide great reportings if you integrate tracking in your DevOps pipelines (and thus, in you Quality Assurance plan).\r\n\r\n[Some great tools](https://www.simoahava.com/analytics/automated-tests-for-google-tag-managers-datalayer/) let you automatically test your DataLayer, but sometimes it is not enough: you not only want to test `pageview`s, but also `event`s like clicks and Ecommerce. You might want to test tracking in various environments like Single Page Application, AMP or Mobile Applications. GAUnit lets you do just that.\r\n\r\n## Contributing\r\n\r\nGAUnit can be useful for several companies. Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\r\n\r\n## Licence\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENCE) file for details.\r\n\r\n## Acknowledgments\r\n\r\nGAUnit was inspired by [WAUnit](https://github.com/joaolcorreia/WAUnit). We decided to create a new library compatible with Python 3 and easier to set up.\r\n\r\n## Roadmap\r\n\r\n- Mobile Apps\r\n- Tracking plan using analytics.js, GTM or GA4 API syntax\r\n- Dockerize (for simpler set up and CI/CD)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincecabs%2Fgaunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvincecabs%2Fgaunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincecabs%2Fgaunit/lists"}