altf1be_google_analytics_helpers
Helpers for Google Analytics facilitating the setting of the categories, actions, labels, User Id and User Agents.
See https://bitbucket.org/altf1be/altf1be_google_analytics_helpers
Google Analytics: https://analytics.google.com
Author: Abdelkrim BOUJRAF, http://www.alt-f1.be
Usage
- Create a .env including this parameter COM_GOOGLE_ANALYTICS_TRACKING_ID
export COM_GOOGLE_ANALYTICS_TRACKING_ID=G-XXXXXXXXXX
- Install python-dotenv
pip install python-dotenv
- load the .env in your entry point (app.py, main.py, test.py)
from dotenv import load_dotenv
load_dotenv()
- Run the code and check if the event is set on Google Analytics
from altf1be_google_analytics_helpers import GoogleAnalytics
import requests
googleAnalytics = GoogleAnalytics()
USER_ID: int, 0 if you DO NOT store a user_id
googleAnalytics.track_event(
category="set a category",
action="set an action",
label="set a label",
value=0,
ua=request.headers.get("User-Agent"),
)
installation
dependencies
Build this package
Documentation to build a Python package
License
Copyright (c) ALT-F1 SPRL, Abdelkrim BOUJRAF. All rights reserved.
Licensed under the EUPL License, Version 1.2.
See LICENSE in the project root for license information.