digital-analytics-toolkit 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,292 @@
1
+ Metadata-Version: 2.4
2
+ Name: digital-analytics-toolkit
3
+ Version: 0.1.0
4
+ Summary: Toolkit for Google Analytics, Google Tag Manager, and BigQuery workflows
5
+ Author: Isha Panchal, Kris Dsouza
6
+ Maintainer-email: Isha Panchal <hacker.knight177@gmail.com>, Kris Dsouza <kris.dsouza64@gmail.com>
7
+ License-Expression: LicenseRef-Proprietary
8
+ Requires-Python: >=3.12
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: pandas
12
+ Requires-Dist: numpy
13
+ Requires-Dist: google-auth
14
+ Requires-Dist: google-analytics-data
15
+ Requires-Dist: google-analytics-admin
16
+ Requires-Dist: google-api-python-client
17
+ Requires-Dist: gspread
18
+ Requires-Dist: google-cloud-bigquery
19
+ Requires-Dist: db-dtypes
20
+ Dynamic: license-file
21
+
22
+ # 🚀 Digital Analytics Toolkit
23
+
24
+ ### A Python toolkit for Google Analytics 4, Google Tag Manager, and BigQuery workflows
25
+
26
+ **Digital Analytics Toolkit** is a Python library designed to streamline GA4 reporting, GA4 administration, audience management, GTM container inspection, and BigQuery querying through reusable Python functions and clients.
27
+
28
+ ---
29
+
30
+ ## 📦 Installation
31
+
32
+ Install the latest release from PyPI:
33
+
34
+ ```bash
35
+ pip install digital-analytics-toolkit
36
+ ```
37
+
38
+ For future upgrade:
39
+
40
+ ```bash
41
+ pip install --upgrade digital-analytics-toolkit
42
+ ```
43
+
44
+ ---
45
+
46
+ ## 🔐 Authentication
47
+
48
+ Digital Analytics Toolkit supports **Service Account Key JSON files** and **Google OAuth2 Credentials**.
49
+
50
+ 1. Create a Service Account in the [Google Cloud Console](https://console.cloud.google.com/).
51
+ 2. Enable necessary APIs:
52
+ - Google Analytics Data API
53
+ - Google Analytics Admin API
54
+ - Google Tag Manager API
55
+ - BigQuery API
56
+ 3. Download the JSON key file and share your GA4 property / GTM account access with the service account email.
57
+
58
+ ---
59
+
60
+ ## 🧩 Features & Module Usage
61
+
62
+ The toolkit is organized into 4 primary functional areas:
63
+
64
+ 1. [GA4 Free-Form & Funnel Reporting](#1-ga4-reporting)
65
+ 2. [GA4 Admin & Audience Management](#2-ga4-admin--audiences)
66
+ 3. [Google Tag Manager (GTM) Operations](#3-google-tag-manager-gtm)
67
+ 4. [BigQuery Integration](#4-bigquery-integration)
68
+
69
+ ---
70
+
71
+ ### 1. GA4 Reporting
72
+
73
+ #### 📊 Free-Form Reports (`free_form_report_GA4`)
74
+ Run custom GA4 reports specifying metrics, dimensions, date ranges, and optional dimension/metric filters.
75
+
76
+ ```python
77
+ from digital_analytics_toolkit import free_form_report_GA4, dimension_filter_generation
78
+
79
+ # Initialize client
80
+ report_client = free_form_report_GA4(
81
+ service_account_file="path/to/service_account.json",
82
+ property_id="123456789"
83
+ )
84
+
85
+ # Optional: Generate dimension filter
86
+ dim_filter = dimension_filter_generation(
87
+ operator="CONTAINS",
88
+ value="Organic",
89
+ dimension_name="sessionDefaultChannelGroup"
90
+ )
91
+
92
+ # Generate report
93
+ df = report_client.free_form_report(
94
+ start_date="30daysAgo",
95
+ end_date="today",
96
+ metrics=["activeUsers", "eventCount", "conversions"],
97
+ dimensions=["date", "sessionDefaultChannelGroup"],
98
+ dimension_filter=dim_filter
99
+ )
100
+
101
+ print(df.head())
102
+ ```
103
+
104
+ #### 🏆 Multi-Step Funnel Reports (`Funnel_Reports`)
105
+ Generate multi-step funnel analysis with support for breakdown dimensions based on funnel step definitions configured in Google Sheets.
106
+
107
+ ```python
108
+ from digital_analytics_toolkit import Funnel_Reports
109
+
110
+ funnel = Funnel_Reports(
111
+ reporting_client="path/to/service_account.json",
112
+ prop_id="123456789"
113
+ )
114
+
115
+ # Run funnel report using steps defined in a Google Sheet
116
+ response = funnel.funnel_report(
117
+ startDate="2024-01-01",
118
+ endDate="2024-01-31",
119
+ file_n="My_Funnel_Steps_Sheet_Name",
120
+ breakdown="deviceCategory",
121
+ breakdown_limit="5"
122
+ )
123
+ ```
124
+
125
+ #### 📜 Dimension & Metric Metadata (`get_dimension_metric`)
126
+ Fetch all available custom & standard dimensions/metrics for a GA4 property and export to CSV.
127
+
128
+ ```python
129
+ from digital_analytics_toolkit import utils
130
+
131
+ utils.get_dimension_metric(
132
+ service_account_file="path/to/service_account.json",
133
+ property_id="123456789",
134
+ file_name="ga4_dimensions_metrics"
135
+ )
136
+ ```
137
+
138
+ ---
139
+
140
+ ### 2. GA4 Admin & Audiences
141
+
142
+ #### 🏢 Accounts & Property Discovery
143
+ Discover accounts, properties, key events (conversions), and BigQuery links.
144
+
145
+ ```python
146
+ from google.oauth2 import service_account
147
+ from digital_analytics_toolkit import (
148
+ get_ga4_accounts_list,
149
+ get_ga4_properties_list,
150
+ get_ga4_property_keyEvents,
151
+ get_ga4_property_bq_link
152
+ )
153
+
154
+ creds = service_account.Credentials.from_service_account_file(
155
+ "path/to/service_account.json",
156
+ scopes=["https://www.googleapis.com/auth/analytics.readonly"]
157
+ )
158
+
159
+ # List accounts & properties
160
+ accounts_df = get_ga4_accounts_list(creds)
161
+ properties_df = get_ga4_properties_list(creds, account_id="12345678")
162
+
163
+ # Key events & BigQuery export status
164
+ key_events_df = get_ga4_property_keyEvents(creds, property_id="123456789")
165
+ bq_links_df = get_ga4_property_bq_link(creds, property_id="123456789")
166
+ ```
167
+
168
+ #### 🎯 Audience Creation (`GA4AudienceClient`)
169
+ Programmatically construct and create GA4 audiences using a simplified dictionary condition language.
170
+
171
+ ```python
172
+ from digital_analytics_toolkit import GA4AudienceClient
173
+
174
+ client = GA4AudienceClient(credentials_path="path/to/service_account.json")
175
+
176
+ audience = client.create_audience(
177
+ property_id="123456789",
178
+ display_name="High Intent Purchasers",
179
+ description="Users with > 3 sessions who completed a purchase",
180
+ membership_duration_days=30,
181
+ scope="ACROSS_ALL_SESSIONS",
182
+ include_conditions=[
183
+ {"type": "event", "event_name": "purchase"},
184
+ {"type": "numeric", "field_name": "sessionCount", "operation": "GREATER_THAN", "value": 3}
185
+ ]
186
+ )
187
+ print(f"Created audience: {audience.name}")
188
+ ```
189
+
190
+ ---
191
+
192
+ ### 3. Google Tag Manager (GTM)
193
+
194
+ Inspect accounts, containers, workspaces, tags, triggers, variables, built-in variables, and custom templates.
195
+
196
+ ```python
197
+ from google.oauth2 import service_account
198
+ from digital_analytics_toolkit import (
199
+ get_accounts,
200
+ get_containers,
201
+ get_workspaces,
202
+ get_tags,
203
+ get_triggers,
204
+ get_variables,
205
+ get_built_in_variables,
206
+ get_custom_templates
207
+ )
208
+
209
+ creds = service_account.Credentials.from_service_account_file(
210
+ "path/to/service_account.json",
211
+ scopes=["https://www.googleapis.com/auth/tagmanager.readonly"]
212
+ )
213
+
214
+ # List accounts & containers
215
+ gtm_accounts = get_accounts(creds)
216
+ containers_df = get_containers(creds, account_id="123456")
217
+
218
+ # Inspect workspace assets
219
+ workspace_id = get_workspaces(creds, account_id="123456", container_id="987654")
220
+ tags = get_tags(creds, account_id="123456", container_id="987654", workspace_id=workspace_id)
221
+ triggers = get_triggers(creds, account_id="123456", container_id="987654", workspace_id=workspace_id)
222
+ variables = get_variables(creds, account_id="123456", container_id="987654", workspace_id=workspace_id)
223
+ ```
224
+
225
+ ---
226
+
227
+ ### 4. BigQuery Integration
228
+
229
+ Run custom SQL queries or extract full tables directly into Pandas DataFrames.
230
+
231
+ ```python
232
+ from digital_analytics_toolkit import bq_functions
233
+
234
+ service_account_file = "path/to/service_account.json"
235
+ project_id = "my-gcp-project"
236
+
237
+ # List Datasets
238
+ datasets = bq_functions.list_bq_datasets(credentials=None, gcp_project_id=project_id)
239
+
240
+ # Execute SQL query to DataFrame
241
+ query = """
242
+ SELECT event_name, COUNT(1) AS event_count
243
+ FROM `my-gcp-project.analytics_123456789.events_*`
244
+ WHERE _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d', CURRENT_DATE())
245
+ GROUP BY 1
246
+ """
247
+ df = bq_functions.get_ga4_data_from_bq(
248
+ project_id=project_id,
249
+ query=query,
250
+ service_account_file=service_account_file
251
+ )
252
+ ```
253
+
254
+ ---
255
+
256
+ ## 🛠 Project Structure
257
+
258
+ ```
259
+ digital-analytics-toolkit/
260
+ ├── pyproject.toml
261
+ ├── README.md
262
+ └── digital_analytics_toolkit/
263
+ ├── __init__.py # Package entrypoint & exported symbols
264
+ ├── free_form_report_GA4.py # GA4 Free-form reporting & dimension filter generation
265
+ ├── funnel_report_GA4.py # GA4 Funnel report engine
266
+ ├── ga4_admin_functions.py # GA4 Admin API helpers (Accounts, Properties, Key Events, BQ Links)
267
+ ├── ga4_audience.py # GA4 Audience creation & condition parser
268
+ ├── gtm_functions.py # Google Tag Manager (GTM) API helper functions
269
+ ├── bq_functions.py # BigQuery query execution & dataset tools
270
+ └── utils.py # Utility functions & metadata extractors
271
+ ```
272
+
273
+ ---
274
+
275
+ ## 💬 Support & Inquiries
276
+
277
+ - For questions, bug reports, or feature requests, contact: **[hacker.knight177@gmail.com](mailto:hacker.knight177@gmail.com)** or **[kris.dsouza64@gmail.com](mailto:kris.dsouza64@gmail.com)**
278
+
279
+ ---
280
+
281
+ ## 📄 License
282
+
283
+ Digital Analytics Toolkit is proprietary software.
284
+
285
+ It is free to install and use for personal, educational, research,
286
+ and commercial purposes.
287
+
288
+ Modification, redistribution, sublicensing, resale, and creation of
289
+ derivative works are not permitted without explicit written
290
+ permission from the copyright holders.
291
+
292
+ See the [LICENSE](LICENSE) file for the complete terms.
@@ -0,0 +1,13 @@
1
+ digital_analytics_toolkit/__init__.py,sha256=ccC5T8co32TvluKz8civbwjqbc8cOZfdJ_jZlPA9_qk,1794
2
+ digital_analytics_toolkit/bq_functions.py,sha256=TyNISH2Jbe_lMWWKNZKeizAoMwFbchq42ucWU0mcMGs,3668
3
+ digital_analytics_toolkit/free_form_report_GA4.py,sha256=lzmd3_e97fJTn1_bZVn3iqBWspIYL3zDXCpKmY6-67c,6834
4
+ digital_analytics_toolkit/funnel_report_GA4.py,sha256=u5cqSkJaEyeWAdwSQP3mfxrIDpRonxSFfPcqYU96K6Q,13113
5
+ digital_analytics_toolkit/ga4_admin_functions.py,sha256=2L4COZ6Q-KIBkp9vF2QXDjIEKxmR0ONZWIteQxde9xM,7309
6
+ digital_analytics_toolkit/ga4_audience.py,sha256=qm7YjzOcwNzyRJ3wHuoBgEPN7ZVe3YhwRUaWlxNnEe0,24073
7
+ digital_analytics_toolkit/gtm_functions.py,sha256=oOLDBC-xm0ahtoCIPFnkt2QzGuYskbn7L-Ndu4inRok,15614
8
+ digital_analytics_toolkit/utils.py,sha256=iXcj9XG3ELrP5D7GklpHhnGV8fF7rOMecQDm7OvnPm8,3663
9
+ digital_analytics_toolkit-0.1.0.dist-info/licenses/LICENSE,sha256=hBIdLwq685fWIv4c3q3FZU5kYdo2DcFsDK4K8U4tKrU,1858
10
+ digital_analytics_toolkit-0.1.0.dist-info/METADATA,sha256=WhBEBz34ttkTFOx2ij-lMi-P1zVaeoKxYq8SzW7yQak,8871
11
+ digital_analytics_toolkit-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
12
+ digital_analytics_toolkit-0.1.0.dist-info/top_level.txt,sha256=X1fwEWD-AgSSUpsQj2BTrgxPsQJp9neRsAE4wkzvXLo,26
13
+ digital_analytics_toolkit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,55 @@
1
+ Copyright (c) 2026 Isha Panchal and Kris Dsouza
2
+
3
+ PROPRIETARY SOFTWARE LICENSE
4
+
5
+ 1. Ownership
6
+
7
+ This software, including its source code, documentation, and associated
8
+ materials, is proprietary software. All copyrights and other intellectual
9
+ property rights in the software are retained by the copyright holders.
10
+
11
+ 2. Permission to Use
12
+
13
+ Permission is granted to any individual or organization to install and use
14
+ this software free of charge for personal, educational, research, or
15
+ commercial purposes.
16
+
17
+ 3. Restrictions
18
+
19
+ Except as expressly permitted by this license, you may not:
20
+
21
+ - modify, alter, or create derivative works of the software;
22
+ - copy or reproduce the software for redistribution;
23
+ - redistribute, republish, sublicense, or sell the software;
24
+ - package or incorporate the software into another publicly distributed
25
+ software package;
26
+ - publish modified or unmodified copies of the software;
27
+ - claim ownership of the software or its source code.
28
+
29
+ 4. Source Code
30
+
31
+ The source code is proprietary and is not licensed for public access,
32
+ modification, or redistribution. The availability of a package through
33
+ PyPI does not grant any rights to access, modify, or redistribute the
34
+ source code beyond the rights explicitly granted by this license.
35
+
36
+ 5. Contributions and Modifications
37
+
38
+ Only individuals expressly authorized by the copyright holders may modify
39
+ the original source code or contribute modifications to the project.
40
+
41
+ 6. No Warranty
42
+
43
+ The software is provided "AS IS", without warranty of any kind, express or
44
+ implied. The copyright holders shall not be liable for any claim, damages,
45
+ or other liability arising from the use of the software.
46
+
47
+ 7. Termination
48
+
49
+ Any rights granted under this license terminate automatically if you
50
+ violate the terms of this license.
51
+
52
+ 8. Copyright
53
+
54
+ Copyright (c) 2026 Isha Panchal and Kris Dsouza.
55
+ All rights reserved.
@@ -0,0 +1 @@
1
+ digital_analytics_toolkit