Share via

Enable analytics for your website to view usage statistics and more.


Hinode supports Google Universal Analytics and Google Analytics 4 out-of-the-box. Simply add your Google property (starting with G- or UA-) to the main configuration in config/_default/config.toml.

googleAnalytics = "G-xxxxxxxxxx"

Default behavior

Review the next sections to understand the default behavior when dealing with web analytics.

Anonymous users

Hinode anonymizes the visitor’s IP address when the client sends a Do Not Track request.

Local development

By default, analytics is disabled when running on a local machine to prevent polution of the gathered insights. Modify the condition (not site.IsServer) as needed.

The file assets/js/analytics.js defines the JavaScript template that is ingested into the main bundle.

    {{- $pc := .Site.Config.Privacy.GoogleAnalytics -}}
    {{- if (and (not .Site.IsServer) (not $pc.Disable)) -}}
    {{- end -}}

The partial layouts/partials/footer/scripts.html loads the Google Tag Manager if applicable (Google Analytics 4 only).

    {{- if and (not site.IsServer) $header -}}
    {{- end -}}

Content Security Policy

Google Analytics requires several Content Security Policies to be set in the server headers.

Google Analytics 4

Hinode has enabled access for Google Analytics 4 by default. The following settings are added to config/_default/server.toml. Similar settings are defined in the netlify.toml file provided in the repository’s root when deploying to Netlify.

script-src:  https://*
img-src:     https://* https://*
connect-src: https://* https://* https://*

Universal Analytics (Google Analytics)

Access for Universal Analytics is not enabled by default. Ensure the following settings are defined in config/_default/server.toml and netlify.toml when applicable.

Last updated: April 27, 2023 • Add analytics docs (bc9046f)