📘
Lab Website Template docs
  • Introduction
    • Overview
    • Is this right for me?
    • Gallery
    • Support
  • Getting Started
    • Set up your site
    • Set up your URL
    • Tidy up your repo
    • Change your site
    • Preview your site
  • Basics
    • Repo structure
    • Configure your site
    • Edit pages
    • Write basic content
    • Use your logo
    • Customize your theme
    • Team members
    • Blog posts
    • Citations
    • Components
      • Section
      • Figure
      • Button
      • Icon
      • Feature
      • List
      • Citation
      • Card
      • Portrait
      • Post Excerpt
      • Alert
      • Tags
      • Float
      • Grid
      • Cols
      • Search
      • Site Search
  • Advanced
    • Update your template
    • Embeds
    • Math, diagrams, videos, etc.
    • Analytics
    • Data and collections
    • Jekyll plugins
    • Custom components
    • Background knowledge
Powered by GitBook
On this page
  1. Advanced

Analytics

Analytics scripts might not be as useful as you think, as most ad blocker extensions now prevent them from working, potentially limiting your data to only a small subset of your visitors.

There are many available analytics services, the most well-known being Google Analytics. They each work slightly differently, but they all should have a way to obtain a snippet of code that you can paste into the pages that you want to track.

The snippet will generally look something like this, a minimal <script> tag with an ID unique to you:

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'UA-XXXXXXXX-X');
</script>

Once you've found this code snippet for your analytics service, paste it into /_includes/analytics.html to include it on every page on your site.

PreviousMath, diagrams, videos, etc.NextData and collections

Last updated 2 years ago