Astro

Autotracking

The quickest way to start pushing events to EnaLog is to use autotrack. Which will automatically track page views, button clicks, and link clicks. You can read more about it here

Setting up Autotrack

You will need to add load the Autotrack script using the client:load directive provided by Astro. You will need to load the script on each page to make sure it tracks page views correctly before the closing <body> tag.

---
---

<html>
  <head>
    <meta charset="utf-8" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <meta name="viewport" content="width=device-width" />
    <meta name="generator" content="{Astro.generator}" />
    <title>{title}</title>
    <meta name="description" content="{description}" />
  </head>
  <body class="min-h-screen max-w-screen">
    <!-- EnaLog Autotrack -->
    <script
      client:load
      defer
      src="https://static.enalog.app/autotrack.min.js"
      data-name="enalog"
      data-enalog-token="<api-token-goes-here>"
      data-enalog-project="<project-slug-goes-here>"
    ></script>
    <!-- End EnaLog Autotrack -->
  </body>
</html>

If you use layouts in Astro - see here for more details, you can move the script tag above into the layout and then atro will load it on every page.