Skip to main content

Google Analytics helpers facilitating the setting of the categories, actions, labels, User Id and User Agents built by www.alt-f1.be

Project description

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

  1. Create a .env including this parameter COM_GOOGLE_ANALYTICS_TRACKING_ID
export COM_GOOGLE_ANALYTICS_TRACKING_ID=G-XXXXXXXXXX
  1. Install python-dotenv
pip install python-dotenv
  1. load the .env in your entry point (app.py, main.py, test.py)
from dotenv import load_dotenv

load_dotenv()
  1. 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, # Event value, must be an integer. i.e. the value of a basket
    ua=request.headers.get("User-Agent"),
)

installation

  • install the package on pypi.org :

    • install : pip install altf1be_google_analytics_helpers
    • upgrade : pip install altf1be_google_analytics_helpers --upgrade
  • install the package on test.pypi.org :

    • install : pip install -i https://test.pypi.org/simple/altf1be_google_analytics_helpers
    • upgrade : pip install -i https://test.pypi.org/simple/altf1be_google_analytics_helpers --upgrade

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

altf1be_google_analytics_helpers-1.0.0.tar.gz (9.7 kB view hashes)

Uploaded Source

Built Distribution

altf1be_google_analytics_helpers-1.0.0-py2.py3-none-any.whl (9.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page