How to include Google Analytics in an RMarkdown generated GitHub Page?
<p>How can I always include the Google Analytics tacking code on my GitHub Pages webpage generated with R Markdown?</p>

<p>I am currently creating a webpage hosted on GitHub Pages using RMarkdown. To create site, I run <code>rmarkdown::render_site()</code>. This command will knit all R Markdown documents to create the relevant <code>.html</code> files.</p>

<p>However, I want to include Google Analytics on my site. To do this, I need to include a University Analytics tracking code to my property by pasting the JavaScript code in my main <code>index.html</code> file. I can easily do this by editing the <code>index.html</code> file directly. However, every time I run <code>rmarkdown::render_site()</code>, to render the site, it re-knits the <code>index.Rmd</code> file, and thus overwrites the <code>index.html</code> file, including the Google Analytics code I previously entered directly.</p>

<p>How can I fix this problem and always have my Google Analytics code contained in the page?</p>