Configuration

Configure Entrolytics for your needs

Configuration

Customize Entrolytics to match your analytics requirements, privacy policies, and technical infrastructure. This guide covers everything from basic tracking script options to advanced custom event tracking.

Tracking Script Configuration

The tracking script supports various configuration options via HTML data attributes:

Standard configuration for most use cases

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

This configuration:

  • Automatically tracks page views
  • Uses default privacy settings
  • Works with all modern browsers

Available Attributes

AttributeTypeDescriptionDefault
data-website-idstringYour website ID (required)-
data-host-urlstringCustom analytics host URLSame as script URL
data-auto-trackbooleanAutomatically track page viewstrue
data-do-not-trackbooleanRespect DNT browser settingtrue
data-cachebooleanEnable localStorage cachingfalse
data-domainsstringComma-separated valid domainsAll domains
data-tagstringA/B test variant tag-
data-exclude-searchbooleanStrip query params from URLsfalse
data-exclude-hashbooleanStrip hash fragments from URLsfalse
data-ignore-localhostbooleanDisable tracking on localhosttrue

SDK Configuration

If you're using one of our framework SDKs, configure via the provider props:

app/layout.tsx
import { EntrolyticsProvider } from '@entrolytics/nextjs-sdk'

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <EntrolyticsProvider
          websiteId={process.env.NEXT_PUBLIC_ENTROLYTICS_WEBSITE_ID!}
          host={process.env.NEXT_PUBLIC_ENTROLYTICS_HOST}
          autoTrack={true}
          respectDoNotTrack={false}
          excludeSearch={false}
          excludeHash={false}
          domains={['example.com', 'www.example.com']}
          tag="homepage"
          debug={process.env.NODE_ENV === 'development'}
        >
          {children}
        </EntrolyticsProvider>
      </body>
    </html>
  )
}

Custom Events

Track any user interaction beyond page views:

Basic Event Tracking

// Simple event
entrolytics.track('button_click');

// Event with properties
entrolytics.track('signup_complete', {
  plan: 'pro',
  trial: false
});

// Event with revenue
entrolytics.track('purchase', {
  product: 'enterprise_plan',
  quantity: 1
}, 299.99);

Common Event Patterns

User Identification

Track specific users across sessions:

// Identify user by ID
entrolytics.identify('user-12345');

Privacy Configuration

GDPR Compliance

Domain Filtering

Restrict tracking to specific domains:

<script
  defer
  src="https://entrolytics.dev/script.js"
  data-website-id="your-website-id"
  data-domains="example.com"
></script>

Only tracks on example.com (not www.example.com or subdomains).

Proxy Mode

Bypass ad blockers by proxying the tracking script and API calls through your domain:

Enable Proxy in SDK

app/layout.tsx
<EntrolyticsProvider
  websiteId='your-website-id'
  proxy={{
    enabled: true,
    scriptPath: '/analytics.js',
    collectPath: '/api/collect',
    mode: 'cloak'
  }}
>
  {children}
</EntrolyticsProvider>

Set Up Rewrite Rules

next.config.js
module.exports = {
  async rewrites() {
    return [
      {
        source: '/analytics.js',
        destination: 'https://entrolytics.dev/script.js'
      },
      {
        source: '/api/collect',
        destination: 'https://entrolytics.dev/api/send'
      }
    ];
  }
};

Now tracking requests appear to come from your domain, bypassing most ad blockers.

Advanced Configuration

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;

Or for self-hosted:

Content-Security-Policy:
  script-src 'self' https://analytics.yourdomain.com;
  connect-src 'self' https://analytics.yourdomain.com;

Next Steps