My RPubs Page
Google Analytics
- Copy the provided Google Analytics tracking code:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-CV2648GQMK"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-CV2648GQMK');
</script>
Create a new file called
google-analytics.html
in the same directory as your R Markdown file.Paste the tracking code into the
google-analytics.html
file.Update the YAML header of your R Markdown document to include the Google Analytics code:
---
title: "My RPubs Page"
output:
html_document:
includes:
in_header: google-analytics.html
---
Publish your R Markdown document to RPubs as usual. The Google Analytics tracking code will now be included in your published RPubs page.
View your Google Analytics dashboard to see the visitor metrics for your RPubs page.
This integration will allow you to track the number of visitors, page views, and other useful analytics for your RPubs content using the Google Analytics platform.