PyGAMP
Google Analytics Measurement Protocol for Python
PyGAMP is a simple implementation of the Google Analytics Measurement Protocol API, which provides a server-side means of passing data into GA, whether it's from a web application, mobile app or server-based application.
Installation
PyGAMP can be installed via PyPi by issuing the command pip3 install pygamp.
Features
PyGAMP currently supports the following features of Google Analytics Measurement Protocol:
- App screenviews
- Exceptions
- Pageviews
- Event tracking
- Social interactions
- Custom dimensions
- Custom metrics
- Ecommerce tracking
- Enhanced ecommerce tracking
- Internal promotions
- Item and transaction refunds
- Checkout options
- Checkout steps
Examples
Refunding an item
refund_items(client_id, 'UA-123456-1', '12345', 'ABC1', 1)
Refunding a transaction
refund_transaction(client_id, 'UA-123456-1', '12345')
Record a promotion impression
promotion_impression(client_id, 'UA-123456-1', 'example.com', 'about-us', 'About us', 2, 'PROMO1', 'Summer sale', 'Summer', 'Slot 1')
Record a promotion click
promotion_click(client_id, 'UA-123456-1', 2, 'PROMO1', 'Summer sale', 'Summer', 'Slot 1')
Assign a value to a custom dimension
custom_dimension(client_id, 'UA-123456-1', '2', 'Analytics')
Assign a value to a custom metric
custom_metric(client_id, 'UA-123456-1', '1', '1234')
Create an interactive event
event(client_id, 'UA-123456-1', 'NI event', 'action', 'label', 10, 1)
Create a non-interactive event
event(client_id, 'UA-123456-1', 'I event', 'action', 'label', 10, 0)
Record a pageview
pageview(client_id, 'UA-123456-1', '/hello', 'example.com', 'Test')
Record a social interaction
social(client_id, 'UA-123456-1', 'like', 'facebook', '/home')
Record an exception
exception(client_id, 'UA-123456-1', 'Transaction not found', 1)
Record an application view
screenview(client_id, 'UA-123456-1', 'PyGAMP', '1.0.1', 'Example')
Record an enhanced ecommerce transaction
To record a transaction using enhanced ecommerce, you first need to construct a nested dictionary of items to push to Google Analytics along with the transaction data. This should use the following format:
items = {
1: {'product_id': 'ABC1',
'product_name': 'Product 1',
'product_price': 19.99,
'product_quantity': 1,
'product_brand': 'Apple',
'product_category': 'Phones',
'product_variant': '256GB',
},
2: {'product_id': 'ABC2',
'product_name': 'Product 2',
'product_price': 20.99,
'product_quantity': 2,
'product_brand': 'Apple',
'product_category': 'Phones',
'product_variant': '500GB',
},
3: {'product_id': 'ABC3',
'product_name': 'Product 3',
'product_price': 39.99,
'product_quantity': 3,
'product_brand': 'Apple',
'product_category': 'Phones',
},
}
This is then passed to GA using the following method:
enhanced_transaction(client_id, 'UA-123456-1', 'example.com', '/order', 'Order complete', '12345', 199.99, 40.00, 0.00, '', items)
Metadata
Release files for pygamp 0.113
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pygamp-0.113.tar.gz | 7.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygamp-0.113-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.7 kB
Release files / pygamp-0.113.tar.gz
| Download URL | pygamp-0.113.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1649be9f2a66592322a4280c9639953b1dff2230310419ce06e3a2e32d56f1a7
|
|
BLAKE2b-256 checksum How to use checksums |
c892764a8147377c9720bb012ea5c48ee2df0e043334613b08a8d13e5205291d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.4.2 requests/2.26.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.62.1 CPython/3.8.10
|
Release files / pygamp-0.113-py3-none-any.whl
| Download URL | pygamp-0.113-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24de21d72b75fab77a717671d440b572ca1a3839a09dc722ec61f04d620de6fe
|
|
BLAKE2b-256 checksum How to use checksums |
42af39431cb63b8b66064554f5bcd316895c6125582cfdcea9d6dfaa1cb0ea84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.4.2 requests/2.26.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.62.1 CPython/3.8.10
|
Security for pygamp 0.113
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.