Tracking the traffic to webpages


Haky Im


July 26, 2021

To keep track of traffic to blogdown (hugo-based) webpages in google analytics, follow the steps below

See Google’s instructions here. Briefly

  1. Sign in to your Analytics account.
  2. Click Admin.
  3. Select an account from the menu in the ACCOUNT column.
  4. Select a property from the menu in the PROPERTY column.
  5. 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

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-61894206-2');
  1. Copy the code above to the site’s layout head_custom.html file. For example for predictdb website, the file is found in
  2. Paste it immediately after the <head> tag on each page of your site.