### Install astro-analytics with npm, pnpm, or yarn Source: https://github.com/destiner/astro-analytics/blob/main/README.md Install the astro-analytics package using npm, pnpm, or yarn. Choose one of the three commands. ```bash npm install astro-analytics # or pnpm install astro-analytics # or yarn add astro-analytics ``` -------------------------------- ### GoogleAnalytics Usage Examples Source: https://github.com/destiner/astro-analytics/blob/main/_autodocs/api-reference/google-analytics.md Two usage examples: the first hard-codes the tracking ID, the second passes the ID from the site's frontmatter configuration, choosing between production and development IDs based on `Astro.site`. Both import `GoogleAnalytics` from the package root. ```astro --- import { GoogleAnalytics } from 'astro-analytics'; --- ``` ```astro --- import { GoogleAnalytics } from 'astro-analytics'; const GA_ID = Astro.site?.includes('example.com') ? 'UA-156492295-1' : 'UA-DEV-1'; --- ``` -------------------------------- ### Matomo emitted markup example Source: https://github.com/destiner/astro-analytics/blob/main/_autodocs/api-reference/matomo.md Example emitted markup when `url = "https://yourdomain.com"` and `id = "1"`. Shows the resolved tracker and endpoint URLs. ```html ``` -------------------------------- ### Plausible emitted markup with default src Source: https://github.com/destiner/astro-analytics/blob/main/_autodocs/api-reference/plausible.md Example of the emitted markup with the default `src` and `domain = "yourdomain.com"`. ```html ``` -------------------------------- ### Usage example with Fathom component Source: https://github.com/destiner/astro-analytics/blob/main/_autodocs/api-reference/index.md Shows how to use the package in an Astro project. Imports the Fathom component and places it in the head with a site prop. All nine components emit script and inline define:vars markup where placed. ```astro --- import { Fathom } from 'astro-analytics'; --- … ``` -------------------------------- ### Rendered script tag and example output Source: https://github.com/destiner/astro-analytics/blob/main/_autodocs/api-reference/umami.md The component renders a single script tag with defer, src as concatenation of site and host, and data-website-id attribute. The second block shows the emitted markup with example values; no URL normalization is performed, so a trailing slash in site would produce a double slash. ```html ``` ```html ``` -------------------------------- ### Emitted script with example ID Source: https://github.com/destiner/astro-analytics/blob/main/_autodocs/api-reference/minimal-analytics.md The full rendered script when `id = "UA-156492295-1"`. It includes the tracking logic and the fixed options object. The script is deferred and inline. ```HTML ``` -------------------------------- ### Fathom component rendered markup with defaults Source: https://github.com/destiner/astro-analytics/blob/main/_autodocs/api-reference/fathom.md Example of the rendered markup with the default `src` and a sample `site` ID. ```html ``` -------------------------------- ### Metrical Emitted Markup with app='j5gZ1K26a' Source: https://github.com/destiner/astro-analytics/blob/main/_autodocs/api-reference/metrical.md Example output when `app` is set to 'j5gZ1K26a', showing the literal app ID in the `window.metrical` object. ```html ``` -------------------------------- ### Plausible Component Source: https://github.com/destiner/astro-analytics/blob/main/_autodocs/api-reference/plausible.md Documentation for the Plausible Astro component, including its props, rendered markup, and usage examples. ```APIDOC ## [COMPONENT] Plausible ### Description Astro component that embeds the Plausible analytics tracker script into a page. It renders a single script tag with the provided domain and optional source URL. ### Import ```ts import { Plausible } from 'astro-analytics'; ``` ### Props - **domain** (string) - Required - Plausible site domain, emitted as the `data-domain` attribute of the tracker script tag. - **src** (string) - Optional - URL of the Plausible tracker script. Defaults to `'https://plausible.io/js/script.js'`. Omit to use the Plausible-hosted script, or pass a custom URL for self-hosted Plausible. ### Rendered Markup With default `src` and `domain = "yourdomain.com"`: ```html ``` The tag is marked `defer`, so the script executes after the HTML is parsed. The component returns no value; it renders only this fragment — no comments, no `