Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Where to install Google GA4 tag

Started by Stephan Burckhardt 3 years ago · 3 replies · 474 views
3 years ago

Where do I install the GA4 header tag (on each page), since there does not seem to be a "header" tag in GRAV?

3 years ago

@stephanckdt, Template partials/base.html.twig is used by Quark as the base template for all inheriting templates like default.html.twig, blog.html.twig, etc.

I presume other themes follow the same logic.

If you inject the GA4 script in template partials/base.html.twig directly below the <head> element, all pages will contain the GA4 script.

3 years ago

@pamtbaau:
partials/base.html.twig

Thanks a lot, Pam. I'm non-techie. So where is the partials/base.html.twig on my GRAV backend to be found so I can insert the code? I'd appreciate step-by step.

3 years ago

@stephanckdt, In most themes, if not all, template base.html.twig can be found in folder /user/themes/yourtheme/templates/partials.

Be aware when updating a theme which you have downloaded, that you may loose your changes when a new version of the theme gets released. To prevent the loss of your changes, you should first create a child theme that inherits from your downloaded theme and make changes only in the newly created child theme. See Inheriting using the CLI.

Alternatively, you could use a plugin that loads the Analytics script, but unfortunately, none supports GA4 at the moment.

last edited 05/16/23 by pamtbaau

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 94 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 146 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 60 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 254 1 year ago