Tracking Script

Add the Entrolytics tracking script to your website

Tracking Script

The Entrolytics tracking script is lightweight (under 1KB), privacy-focused, and easy to install. This guide covers installation methods for all major platforms and frameworks.

Why Use the Tracking Script?

  • Incredibly lightweight - Less than 1KB gzipped
  • 🚀 No performance impact - Async loading, non-blocking
  • 🔒 Privacy-first - No cookies, GDPR compliant
  • 📊 Automatic tracking - Page views tracked automatically
  • 🎯 Custom events - Track any user interaction
  • 🌐 Universal - Works with any website or framework

Basic Installation

Add this script to your website's <head> tag:

<!DOCTYPE html>
<html>
  <head>
    <title>My Website</title>

    <!-- Entrolytics Tracking Script -->
    <script
      defer
      src="https://entrolytics.dev/script.js"
      data-website-id="YOUR_WEBSITE_ID"
    ></script>
  </head>
  <body>
    <!-- Your content -->
  </body>
</html>

Replace YOUR_WEBSITE_ID with your actual Website ID from the dashboard.

Platform-Specific Guides

Content Management Systems

Option 1: Use the Entrolytics WordPress Plugin (Recommended)

Install from WordPress Plugin Directory or see WordPress integration.

Option 2: Add Manually

Edit Theme Header

Go to AppearanceTheme Editorheader.php

Add Script

Add before </head>:

<!-- Entrolytics -->
<script
  defer
  src="https://entrolytics.dev/script.js"
  data-website-id="<?php echo esc_attr( get_option('entrolytics_website_id') ); ?>"
></script>

Save Changes

Click Update File

Option 3: Use a Plugin

  • Insert Headers and Footers
  • WPCode (formerly Insert Headers and Footers)
  • Head, Footer and Post Injections

E-commerce Platforms

Option 1: Use the Entrolytics Shopify App (Recommended)

Install from Shopify App Store for automatic setup.

Option 2: Add Manually

Edit Theme

Go to Online StoreThemesActionsEdit code

Open theme.liquid

Find theme.liquid in the Layout folder

Add Script

Add before </head>:

<!-- Entrolytics -->
<script
  defer
  src="https://entrolytics.dev/script.js"
  data-website-id="YOUR_WEBSITE_ID"
></script>

Save

Click Save and preview your store

Static Site Generators

Use the @entrolytics/astro-sdk SDK (Recommended)

Or add to your base layout:

src/layouts/Layout.astro
---
const { title } = Astro.props;
---

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>{title}</title>

    <!-- Entrolytics -->
    <script
      is:inline
      defer
      src="https://entrolytics.dev/script.js"
      data-website-id={import.meta.env.PUBLIC_ENTROLYTICS_WEBSITE_ID}
    ></script>
  </head>
  <body>
    <slot />
  </body>
</html>

Manual Page View Tracking

For single-page applications or custom routing:

Disable Auto-Tracking

<script
  defer
  src="https://entrolytics.dev/script.js"
  data-website-id="YOUR_WEBSITE_ID"
  data-auto-track="false"
></script>

Track Page Views Manually

// Track current page
entrolytics.track();

// Track custom page
entrolytics.track({
  url: '/virtual-page',
  referrer: document.referrer,
  title: 'Custom Page Title'
});

// Track on route change
window.addEventListener('popstate', () => {
  entrolytics.track();
});

Verification

Check that tracking is working correctly:

Visit Your Website

Open your website in a new browser window.

Check Network Tab

  1. Press F12 or Cmd+Option+I (Mac)
  2. Click Network tab
  3. Filter by "script.js" or "send"
  4. Reload the page
  5. Look for requests to entrolytics.dev

Successful: Status 200, green indicators Failed: Red status, check console for errors

Check Dashboard

  1. Open your Entrolytics dashboard
  2. Go to Real-time view
  3. Your visit should appear within 1-2 seconds

Test Custom Events

// Open browser console (F12)
entrolytics.track('test_event', { test: true })

Check dashboard for the custom event.

Content Security Policy

If your site uses CSP headers, add Entrolytics to the allowlist:

Content-Security-Policy:
  script-src 'self' https://entrolytics.dev;
  connect-src 'self' https://entrolytics.dev;

Troubleshooting

Advanced Configuration

Proxy Mode

Bypass ad blockers by proxying requests through your domain:

See Proxy Configuration for full setup.

Custom Domain

Use your own domain for self-hosted instances:

<script
  defer
  src="https://analytics.yourdomain.com/script.js"
  data-website-id="YOUR_WEBSITE_ID"
  data-host-url="https://analytics.yourdomain.com"
></script>

Debug Mode

Enable console logging:

<script
  defer
  src="https://entrolytics.dev/script.js"
  data-website-id="YOUR_WEBSITE_ID"
  data-debug="true"
></script>

All tracking calls will be logged to the console.

Best Practices

Next Steps