gohugo-amp

Analytics configuration

From the base configuration the following attributes are relevant if you are using google analytics to measure your websites traffic. All the configuration parameters living in the [params] section of your config.toml in the root folder of your HUGO project.

analytics

googleAnalytics

googleAnalytics = "UA-123456-78"

your UA-Tracking code. Here you will find a guide how to find your UA-Code.


Event Triggers

Its recommended to use custom event triggers. You can define them in a custom JSON-File /data/analytics/triggers.json. A simple example you find below:

{
  "trackPageview": {
    "on": "visible",
    "request": "pageview"
  },
  "trackEvent" : {
    "selector": "body",
    "on": "click",
    "request": "event",
    "vars": {
      "eventCategory": "body-click",
      "eventAction": "click"
    }
  }
}

For further possible triggers please head to the official AMP Analytics Documentation with some advanced examples.