Installation

To install google analytics on your website take the following steps within the Google Analytics dashboard:

Google universal code

  1. Go to admin > tracking info > tracking code
  2. Copy and paste the code as the first item into the head tag of the webpage

Example of a script:

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

  gtag('config', '[TRACKING_ID]');
</script>

Instead of TRACKING_ID use your own tracking id.

GA4 code

  1. Go to admin > setup assistant > tag installation > data stream > globat site tag
  2. Copy the global site tag into the head tag section of your HTML. Or, if you use a website builder (e.g. WordPress, Shopify, etc)

Example of a GA4 script:

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

  gtag('config', '[TRACKING_ID');
</script>

You can find more information here