Skip to main content

Datasette plugin that adds Google Analytics tracking code to your Datasette instance

Reason this release was yanked:

The current version is not functioning as intended. Please use 0.1.2 and above.

Project description

datasette-google-analytics

A Datasette plugin that adds Google Analytics tracking code to your Datasette instance.

Installation

Install this plugin in the same environment as Datasette:

pip install datasette-google-analytics

Usage

Configure the plugin by adding a metadata.json file with your Google Analytics tracking ID:

{
    "plugins": {
        "datasette-google-analytics": {
            "tracking_id": "G-XXXXXXXXXX"
        }
    }
}

Replace G-XXXXXXXXXX with your actual Google Analytics 4 tracking ID.

Then start Datasette with:

datasette --metadata metadata.json your-database.db

Development

To set up this plugin locally:

cd datasette-google-analytics
python -m venv venv
source venv/bin/activate
pip install -e '.[test]'

How This Works

  1. The plugin creates a custom template that extends the default base template
  2. It uses the extra_template_vars hook to pass the Google Analytics tracking ID to the template
  3. It uses the prepare_jinja2_environment hook to modify the Jinjia2 environment by adding our template directories
  4. The custom template adds the Google Analytics tracking code in the extra_head block

This approach follows Google's recommendations for placing the tracking code immediately after the <head> element.

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

datasette_google_analytics-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datasette_google_analytics-0.1.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file datasette_google_analytics-0.1.1.tar.gz.

File metadata

File hashes

Hashes for datasette_google_analytics-0.1.1.tar.gz
Algorithm Hash digest
SHA256 51f8baa2eb75f292d1dbe8175d01f6540bc9924b6b6808063589edf4f89785e9
MD5 f0a857957ea04f8955edfc3097877925
BLAKE2b-256 e3b3a11ab12bb1ec5349bab07688af9a9c8078ed74e48567faeba37fec4e2c6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_google_analytics-0.1.1.tar.gz:

Publisher: release.yml on ngshiheng/datasette-google-analytics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file datasette_google_analytics-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_google_analytics-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc5b186ef533912dbc4708a4ea1a9b560ffedf2eb2509cfe7c30831da544eb92
MD5 ef2e7795892a1f258c3f5e562c6115b3
BLAKE2b-256 d44f720d634936ca63a8807b432c74018d65d8998744e4f251971d64d4569bda

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_google_analytics-0.1.1-py3-none-any.whl:

Publisher: release.yml on ngshiheng/datasette-google-analytics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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