Skip to content
Features Integrations Pricing Docs

Installing the tracker

The tracker (t.js) weighs about 2 KB, sets no cookies, writes nothing to the visitor's device and never slows down page rendering (defer).

HTML snippet

<script defer src="https://byanalytics.co.unikaweb.es/t.js" data-site="YOUR_SITE_KEY"></script>

Put it in the <head> of every page. Your site key is in Site settings → Install.

Optional attributes

Attribute Purpose
data-api="https://…/api/e" Send events to a custom endpoint (for example a first-party proxy).
data-hash Count #hash changes as page views (hash-based routers).
data-local Also track on localhost (off by default).

Single-page apps

React, Vue, Svelte, Next.js, Nuxt and any app using the History API are tracked automatically: every pushState or popstate becomes a page view. Astro View Transitions are supported out of the box.

Astro

Use the component from integrations/astro:

---
import ByAnalytics from '../components/ByAnalytics.astro';
---
<head>
  <ByAnalytics site="YOUR_SITE_KEY" />
</head>

Laravel

composer require byanalytics/laravel

Set BYANALYTICS_SITE_KEY in your configuration and add the Blade component to your layout:

<x-byanalytics />

The package can also send server-side events through the Events API.

WordPress & WooCommerce

Install the byanalytics plugin from integrations/wordpress, open Settings → byanalytics and paste your site key. WooCommerce purchases are recorded as purchase events with their order total as revenue.

Verify the installation

Open your site in a normal browser window, then check Realtime in byanalytics. The install wizard also polls for the first event and turns green when it arrives.

Visits are not recorded when:

  • the page runs on localhost (unless data-local is set);
  • the browser is automated (headless browsers, navigator.webdriver);
  • the visitor opted out (see below);
  • the user agent belongs to a known bot — these are counted separately as bot hits.

Exclude your own visits

Run this once in your browser console on your site:

localStorage.setItem('byanalytics_ignore', '1')

Remove the key to be counted again.

Content Security Policy

If your site uses a CSP, allow the script and the collection endpoint:

script-src 'self' https://byanalytics.co;
connect-src 'self' https://byanalytics.co;