Platform Plugins

Third-party platform integrations for seamless analytics

Platform Plugins

Platform plugins provide seamless integration with popular third-party platforms and services. Deploy Entrolytics analytics with zero configuration and automatic setup.

Deployment Platforms

E-commerce Platforms

Content Management

Features

All platform plugins provide:

Automatic Setup

  • Zero Configuration: Install and start tracking immediately
  • Automatic Script Injection: No manual code changes needed
  • Environment Detection: Automatically adapts to development/production
  • Domain Configuration: Automatic domain and SSL setup

Platform Integration

  • Native UI: Integrates with platform dashboard and settings
  • API Integration: Uses platform APIs for enhanced features
  • Data Synchronization: Syncs with platform data and user accounts
  • Workflow Integration: Fits into existing development workflows

Enhanced Analytics

  • Platform-Specific Events: Track platform-specific user actions
  • Conversion Tracking: Built-in conversion and goal tracking
  • E-commerce Analytics: Product, cart, and purchase tracking
  • Content Analytics: Page views, engagement, and content performance

Quick Setup

Vercel

# Install via Vercel CLI
vercel install entrolytics

# Or add to vercel.json
{
  "functions": {
    "api/send.js": {
      "maxDuration": 10
    }
  },
  "build": {
    "env": {
      "ENTROLYTICS_WEBSITE_ID": "@entrolytics_website_id"
    }
  }
}

Netlify

# Install via Netlify CLI
netlify plugins:install @entrolytics/netlify-plugin

# Or add to netlify.toml
[[plugins]]
package = "@entrolytics/netlify-plugin"

  [plugins.inputs]
  website_id = "your-website-id"

Shopify

# Install from Shopify App Store
# 1. Search "Entrolytics" in Shopify App Store
# 2. Click "Add app" and approve permissions
# 3. Configure tracking settings in app dashboard

WordPress

# Install from WordPress.org
# 1. Search "Entrolytics" in WordPress plugin directory
# 2. Click "Install Now" and "Activate"
# 3. Configure settings in Settings > Entrolytics

Configuration

Common Options

All plugins support these common configuration options:

interface PluginConfig {
  /** Website ID (required) */
  websiteId: string
  /** API key for enhanced features */
  apiKey?: string
  /** Custom tracking domain */
  customDomain?: string
  /** Enable automatic event tracking */
  autoTrack?: boolean
  /** Track e-commerce events */
  trackEcommerce?: boolean
  /** Track form submissions */
  trackForms?: boolean
  /** Track file downloads */
  trackDownloads?: boolean
  /** Track outbound links */
  trackOutbound?: boolean
  /** Exclude specific paths */
  excludePaths?: string[]
  /** Include custom properties */
  customProperties?: Record<string, any>
}

Environment Variables

# Common environment variables
ENTROLYTICS_WEBSITE_ID=your-website-id
ENTROLYTICS_API_KEY=your-api-key
ENTROLYTICS_CUSTOM_DOMAIN=analytics.yourdomain.com
ENTROLYTICS_DEBUG=false

Platform-Specific Features

Vercel Integration

Edge Functions

// api/send.js
import { EntrolyticsEdgeFunction } from '@entrolytics/vercel-plugin'

export default EntrolyticsEdgeFunction({
  websiteId: process.env.ENTROLYTICS_WEBSITE_ID,
  apiKey: process.env.ENTROLYTICS_API_KEY
})

Automatic Deployment

{
  "version": 2,
  "functions": {
    "api/send.js": {
      "runtime": "edge"
    }
  },
  "routes": [
    {
      "src": "/api/send",
      "dest": "/api/send.js"
    }
  ]
}

Netlify Integration

Edge Functions

// netlify/functions/send.ts
import { EntrolyticsNetlifyFunction } from '@entrolytics/netlify-plugin'

export const handler = EntrolyticsNetlifyFunction({
  websiteId: process.env.ENTROLYTICS_WEBSITE_ID,
  apiKey: process.env.ENTROLYTICS_API_KEY
})

Form Tracking

# netlify.toml
[[plugins]]
package = "@entrolytics/netlify-plugin"

  [plugins.inputs]
  website_id = "your-website-id"
  track_forms = true
  track_submissions = true

Shopify Integration

E-commerce Events

// Product page tracking
Entrolytics.track('product_view', {
  product_id: product.id,
  product_name: product.title,
  category: product.type,
  price: product.price,
  currency: shop.currency,
  vendor: product.vendor
})

// Add to cart tracking
Entrolytics.track('add_to_cart', {
  product_id: product.id,
  variant_id: variant.id,
  quantity: quantity,
  price: variant.price,
  cart_value: cart.total_price
})

// Purchase tracking
Entrolytics.track('purchase', {
  order_id: order.id,
  total: order.total_price,
  currency: order.currency,
  items: order.line_items.map((item) => ({
    product_id: item.product_id,
    quantity: item.quantity,
    price: item.price
  }))
})

Customer Data

// Customer identification
Entrolytics.identify(customer.id, {
  email: customer.email,
  name: `${customer.first_name} ${customer.last_name}`,
  phone: customer.phone,
  orders_count: customer.orders_count,
  total_spent: customer.total_spent,
  tags: customer.tags
})

WordPress Integration

Content Tracking

// Track post views
entrolytics_track('post_view', [
  'post_id' => get_the_ID(),
  'post_type' => get_post_type(),
  'post_title' => get_the_title(),
  'category' => get_the_category()[0]->name,
  'author' => get_the_author_meta('display_name'),
  'published_date' => get_the_date('c')
]);

// Track form submissions
entrolytics_track('form_submission', [
  'form_id' => $form_id,
  'form_type' => $form_type,
  'user_id' => get_current_user_id(),
  'page_url' => $_SERVER['REQUEST_URI']
]);

User Tracking

// Track user registration
entrolytics_identify($user_id, [
  'email' => $user->user_email,
  'name' => $user->display_name,
  'role' => implode(', ', $user->roles),
  'registration_date' => $user->user_registered
]);

// Track user login
entrolytics_track('user_login', [
  'user_id' => $user_id,
  'login_time' => current_time('c'),
  'remember_me' => isset($_POST['rememberme'])
]);

Advanced Usage

Custom Event Tracking

Vercel Custom Events

// pages/api/custom-event.ts
import { NextApiRequest, NextApiResponse } from 'next'
import { EntrolyticsClient } from '@entrolytics/api-client'

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse
) {
  const client = new EntrolyticsClient({
    websiteId: process.env.ENTROLYTICS_WEBSITE_ID!,
    apiKey: process.env.ENTROLYTICS_API_KEY!
  })

  await client.track(req.body.event, req.body.properties)

  res.status(200).json({ success: true })
}

Netlify Custom Events

// netlify/functions/custom-event.ts
import { Handler } from '@netlify/functions'
import { EntrolyticsClient } from '@entrolytics/api-client'

export const handler: Handler = async (event) => {
  const client = new EntrolyticsClient({
    websiteId: process.env.ENTROLYTICS_WEBSITE_ID!,
    apiKey: process.env.ENTROLYTICS_API_KEY!
  })

  const data = JSON.parse(event.body || '{}')
  await client.track(data.event, data.properties)

  return {
    statusCode: 200,
    body: JSON.stringify({ success: true })
  }
}

Custom Configuration

Environment-Specific Settings

// Vercel - vercel.json
{
  "env": {
    "ENTROLYTICS_WEBSITE_ID": {
      "development": "dev-website-id",
      "production": "@entrolytics_website_id"
    }
  }
}
# Netlify - netlify.toml
[context.production.environment]
ENTROLYTICS_WEBSITE_ID = "prod-website-id"

[context.deploy-preview.environment]
ENTROLYTICS_WEBSITE_ID = "preview-website-id"

Custom Properties

// Global custom properties
const customProperties = {
  app_version: '1.0.0',
  environment: process.env.NODE_ENV,
  build_id: process.env.VERCEL_URL || process.env.NETLIFY_URL,
  platform: 'vercel' // or 'netlify', 'shopify', 'wordpress'
}

Migration Guides

From Google Analytics

Vercel Migration

// Before - Google Analytics
import { GoogleAnalytics } from '@next/third-parties/google'

export default function Layout({ children }) {
  return (
    <html>
      <body>
        <GoogleAnalytics gaId='GA-XXXXXXXXX' />
        {children}
      </body>
    </html>
  )
}

// After - Entrolytics Vercel Plugin
// No code changes needed - automatic injection!

Netlify Migration

<!-- Before - Google Analytics -->
<script
  async
  src="https://www.googletagmanager.com/gtag/js?id=GA-XXXXXXXXX"
></script>
<script>
  window.dataLayer = window.dataLayer || []
  function gtag() {
    dataLayer.push(arguments)
  }
  gtag('js', new Date())
  gtag('config', 'GA-XXXXXXXXX')
</script>

<!-- After - Entrolytics Netlify Plugin -->
<!-- Automatically injected by plugin -->

From Manual Implementation

Shopify Migration

<!-- Before - Manual tracking -->
<script>
  analytics.track('product_view', {
    product_id: {{ product.id }},
    product_name: '{{ product.title }}'
  });
</script>

<!-- After - Shopify Plugin -->
<!-- Automatic tracking - no code needed -->

WordPress Migration

<?php
// Before - Manual tracking
?>
<script>
  analytics.track('page_view', {
    post_id: <?php echo get_the_ID(); ?>,
    post_title: '<?php echo get_the_title(); ?>'
  });
</script>

<?php
// After - WordPress Plugin
// Automatic tracking handled by plugin
?>

Performance Optimization

Edge Optimization

Vercel Edge Functions

// Optimized edge function
import { EntrolyticsEdgeFunction } from '@entrolytics/vercel-plugin'

export default EntrolyticsEdgeFunction({
  websiteId: process.env.ENTROLYTICS_WEBSITE_ID,
  edgeOptimized: true, // Use edge runtime
  cache: 'force-cache', // Cache responses
  compression: true // Enable gzip
})

Netlify Edge Functions

// Optimized edge function
import { EntrolyticsNetlifyFunction } from '@entrolytics/netlify-plugin'

export const handler = EntrolyticsNetlifyFunction({
  websiteId: process.env.ENTROLYTICS_WEBSITE_ID,
  edge: true, // Use edge runtime
  cache: 'long', // Cache for 1 hour
  batchEvents: true // Batch multiple events
})

Caching Strategy

CDN Caching

// Cache configuration for analytics endpoint
const cacheConfig = {
  cacheControl: 'public, max-age=3600', // 1 hour cache
  edgeCache: true, // Edge caching
  staleWhileRevalidate: 86400 // Serve stale while revalidating
}

Local Caching

// Client-side caching
const eventCache = new Map()

function trackEvent(event, properties) {
  // Cache events locally
  const cacheKey = `${event}_${JSON.stringify(properties)}`

  if (!eventCache.has(cacheKey)) {
    eventCache.set(cacheKey, true)

    // Send to analytics
    Entrolytics.track(event, properties)
  }
}

Testing

Plugin Testing

Vercel Plugin Tests

// tests/vercel-plugin.test.ts
import { EntrolyticsEdgeFunction } from '@entrolytics/vercel-plugin'

describe('Vercel Plugin', () => {
  it('should handle analytics requests', async () => {
    const handler = EntrolyticsEdgeFunction({
      websiteId: 'test-website-id'
    })

    const response = await handler({
      method: 'POST',
      body: JSON.stringify({
        event: 'test_event',
        properties: { test: true }
      })
    })

    expect(response.status).toBe(200)
  })
})

Netlify Plugin Tests

// tests/netlify-plugin.test.ts
import { handler } from '../netlify/functions/send'

describe('Netlify Plugin', () => {
  it('should process analytics events', async () => {
    const event = {
      body: JSON.stringify({
        event: 'test_event',
        properties: { test: true }
      })
    }

    const response = await handler(event)

    expect(response.statusCode).toBe(200)
  })
})

Troubleshooting

Best Practices

Support and Resources

Documentation

Community

Support


Platform plugins for Entrolytics - First-party growth analytics for the edge