virling Docs
v0.1.0 virling.com GitHub
virling Docs

Framework guides

The same tag works everywhere. These are the snippets from the app’s setup screen. Replace stats.example.com with your Virling server and yourdomain.com with your site.

HTML

Before </head> on every page:

<script defer src="https://stats.example.com/v.js"
  data-site="yourdomain.com"></script>

Next.js

In the App Router, put it in the root layout so it loads on every route. Route changes are tracked through history.pushState, so client-side navigation is counted.

import Script from "next/script";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <head>
        <Script defer src="https://stats.example.com/v.js"
          data-site="yourdomain.com" />
      </head>
      <body>{children}</body>
    </html>
  );
}

Astro

Use is:inline so Astro leaves the tag as it is instead of bundling it. The script reads its own attributes, which only works on the original tag.

<script is:inline defer src="https://stats.example.com/v.js"
  data-site="yourdomain.com"></script>

WordPress

In Appearance, Theme File Editor, open header.php and paste the tag before </head>. A plugin that inserts code into the header works too, and survives theme updates.

<script defer src="https://stats.example.com/v.js"
  data-site="yourdomain.com"></script>

Framer

Site settings, General, Custom code, then “End of <head> tag”. Publish the site afterwards.

Webflow

Site settings, Custom code, then Head code. Publish the site afterwards.

<script defer src="https://stats.example.com/v.js"
  data-site="yourdomain.com"></script>

Other setups

  • Tag managers. The script reads data-site and the other attributes from its own <script> tag. If a tag manager injects it, make sure the injected tag keeps those attributes.
  • Several domains. Add each domain as its own site and use its own data-site. Subdomains of a site are included automatically.
Was this page helpful?No Edit this page on GitHub