Skip to main content

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

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.2.tar.gz (4.3 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.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for datasette_google_analytics-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b82de366b1f93591150d510a8d8947433db9b3fb08bb382c884415e0218412ab
MD5 1ea8a4176f258861c28b8b852ba6b65c
BLAKE2b-256 703f9222becf080cc17b64f1fcd219f9d1b5971ddac21c21ab319e4a4c5320c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_google_analytics-0.1.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_google_analytics-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1e77be1c9e33ba2a795369e7ef1f7f1d75a73612f4ae37220ecf40da0440411
MD5 7e08ea8d178c41590aad003fb63c0b7c
BLAKE2b-256 2798d03553d551fde8684e3cb9d93593e4c52c55bfe0bdbe4bc72a0f6d0cdf8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_google_analytics-0.1.2-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