Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google analytics on a single distill page? #427

Open
ColinConwell opened this issue Dec 8, 2021 · 1 comment
Open

Google analytics on a single distill page? #427

ColinConwell opened this issue Dec 8, 2021 · 1 comment

Comments

@ColinConwell
Copy link

Question: is it possible to include the google_analytics: 'tracking_id' on a single static distill article? (Generated with rmarkdown::render('name_of_page.Rmd')?

Or is some sort of site rendering necessary?

Ideally, I'd like to be able to add analytics (without manually editing the .html file) without creating an entire site.

@edornshuld
Copy link

edornshuld commented Feb 15, 2022

This can be done by using includes: (see #378)

Create an HTML file with the analytics scripts. I was able to find mine by inspecting an existing page and finding the

  1. googletagmanager script
  2. google-site-verification meta line

Pasting that into the filename.html file and then pointing to it in the YAML did the trick.

Add to YAML:

includes:
   in_header: filename.html

Knit file individually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants