-
Notifications
You must be signed in to change notification settings - Fork 45.7k
Adding Google Analytics
rjzupkoii edited this page Feb 1, 2025
·
3 revisions
In order to track engagement with your site, you may wish to add Google Analytics. After following the steps provided by Google to setup your Google Analytics account, you need to make the following changes to your site:
In /_layouts/default.html
, replace the code after <head>
with:
{% include analytics.html %}
{% include head.html %}
{% include head/custom.html %}
Next, replace all the things in /_includes/analytics.html
with your tag script like:
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<!-- end custom analytics snippet -->
gtag('config', YOUR_TAG');
</script>
Where YOUR_TAG
is the tag provided to you by Google, additional tips for the Google Analytics TAG can be found in Google's FAQ.