Hello. Could someone explain HOW TO connect GAnalytics in simpliest way?
No luck with plugins.
Telegram @emptty0
Plugins
Solved by pamtbaau View solution
Just insert google code into HEADER section in this file
/user/themes/THEME/templates/partials/base.html.twig
@emptty0, That is indeed the most simple way.
To add a bit more flexibility you might consider adding test and production GA ID's in different config files, eg. /user/config/ganalytics.yaml containing the test Id and /user/env/mydomain.com/config/ganalytics.yaml containing the production Id.
HTML
// /user/config/ganalytics.yaml -> Contains default setting
script: '<script>script with test key</script>'
// /user/env/mydomain.com/config/ganalytics.yaml
script: '<script>script with production key</script>'
And in /user/themes/your-theme/templates/partials/base.html.twig:
TWIG
{{ config.ganalytics.script | raw }}
Grav will automatically switch between config files depending on the domain.
Log in to reply.
Suggested topics
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 2 | 80 | 1 week ago | ||
| 2 | 84 | 4 weeks ago | ||
| 3 | 1210 | 1 month ago | ||
| 1 | 77 | 1 month ago | ||
| 3 | 103 | 2 months ago |