Skip to main content

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.

Metadata

Release files for datasette-google-analytics 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datasette-google-analytics 0.1.2
File Size Uploaded
datasette_google_analytics-0.1.2.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datasette-google-analytics 0.1.2
File Interpreter ABI Platform
datasette_google_analytics-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.6 kB

Release files / datasette_google_analytics-0.1.2.tar.gz

Download URL datasette_google_analytics-0.1.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b82de366b1f93591150d510a8d8947433db9b3fb08bb382c884415e0218412ab
BLAKE2b-256 checksum
How to use checksums
703f9222becf080cc17b64f1fcd219f9d1b5971ddac21c21ab319e4a4c5320c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

Release files / datasette_google_analytics-0.1.2-py3-none-any.whl

Download URL datasette_google_analytics-0.1.2-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1e77be1c9e33ba2a795369e7ef1f7f1d75a73612f4ae37220ecf40da0440411
BLAKE2b-256 checksum
How to use checksums
2798d03553d551fde8684e3cb9d93593e4c52c55bfe0bdbe4bc72a0f6d0cdf8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page