pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

Possible to add another HTML option for analytics code?

Open juliasilge opened this issue 1 year ago • 3 comments

I see in the docs that analytics code can be added in the header in_header and after the body after_body. We are being told that the best or "right" place for some Google Tag Manager analytics code is right after the opening <body> tag, not at the end of the body, after it.

Is this something other pkgdown users would find useful? Is it possible to add a new option like that?

juliasilge avatar May 03 '23 22:05 juliasilge

So this means https://github.com/r-lib/pkgdown/blob/c354aa7e5ea1f9936692494c28c89e5bdd31fc68/inst/BS5/templates/head.html#L92 should be moved? I can see the docs don't even mention that built-in GA support actually.

Note that you can use before_body https://github.com/r-lib/pkgdown/blob/c354aa7e5ea1f9936692494c28c89e5bdd31fc68/inst/BS5/templates/layout.html#L11 (I guess it also means the docs need an update?)

maelle avatar May 04 '23 08:05 maelle

Ah, before_body would do it, yes! I am noticing that these are the same three options that Quarto has, which is great.

juliasilge avatar May 04 '23 17:05 juliasilge

I don't have enough information or knowledge to know if the built-in GA support should move, but documenting the before_body option would have set me on the path I needed, based on the instructions from our website team.

juliasilge avatar May 04 '23 17:05 juliasilge