To keep track of traffic to blogdown (hugo-based) webpages in google analytics, follow the steps below
See Google’s instructions here. Briefly
- Sign in to your Analytics account.
- Click Admin.
- Select an account from the menu in the ACCOUNT column.
- Select a property from the menu in the PROPERTY column.
- Under PROPERTY, click Tracking Info > Tracking Code.Your Tracking ID is displayed at the top of the page.
Copy the global site tag, which is several lines of code that you need to paste into each webpage you want to measure. Below is the code for tracking predictdb.org
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-61894206-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-61894206-2');
</script>
- Copy the code above to the site’s layout head_custom.html file. For example for predictdb website, the file is found in
https://github.com/hakyimlab/web-predictdb/blob/main/layouts/partials/head_custom.html
. - Paste it immediately after the
<head>
tag on each page of your site.