Google Analytics

This module offers support for Google Analytics. It’s built on top of Hugo internal Google Analytics template, and port it for HugoPress.

Module
github.com/hugomods/google-analytics
GitHub Stars Used By Used By Used By Used By

Installation

1.Import the Module

hugo.yaml

1module:
2  imports:
3  - path: github.com/hugomods/google-analytics

hugo.toml

1[module]
2[[module.imports]]
3    path = 'github.com/hugomods/google-analytics'

hugo.json

1{
2   "module": {
3      "imports": [
4         {
5            "path": "github.com/hugomods/google-analytics"
6         }
7      ]
8   }
9}

2.Import the Partial

Please skip this step if your theme supports HugoPress, such as HB Framework themes.

1<head>
2  {{ partialCached "google-analytics/index" . }}
3</head>

Site Configuration

ParameterTypeDefaultDescription
googleAnalyticsstring-The measurement ID.

hugo.yaml

1googleAnalytics: G-XXXXXXXXXX

hugo.toml

1googleAnalytics = 'G-XXXXXXXXXX'

hugo.json

1{
2   "googleAnalytics": "G-XXXXXXXXXX"
3}

Page Parameters

NameTypeDefaultDescription
analyzebooleantrueExclude pages from being tracked if false.