Wix Google Analytics Integration | Blue Frog Docs

Wix Google Analytics Integration

Integrate Google Analytics 4 with Wix for comprehensive analytics tracking.

Wix Google Analytics Integration

Complete guide to setting up Google Analytics 4 (GA4) on your Wix site for comprehensive user behavior and conversion tracking.

Overview

Wix provides native Google Analytics 4 integration through the Wix App Market, making it simple to connect your analytics account. The platform offers both a no-code integration through the official Wix Analytics app and custom code options for advanced implementations. Whether you're running a blog, portfolio, or online store, Wix's GA4 integration helps you understand your visitors and optimize your site.

Key Benefits

  • Easy Setup: Connect GA4 through the Wix App Market in minutes
  • Automatic Page Tracking: Page views tracked automatically
  • Ecommerce Integration: Built-in tracking for Wix Stores
  • Custom Tracking: Add custom events through Wix Corvid (Velo)
  • Mobile Optimized: Tracking works seamlessly on mobile devices

Plan Requirements

  • GA4 Integration: Available on all Wix plans
  • Custom Code: Available on premium plans
  • Ecommerce Tracking: Requires Wix Stores/Business & Ecommerce plan
  • Advanced Features: Velo dev mode available on premium plans

Installation Methods

Use the official Wix app for easiest setup.

Step 1: Install Wix Analytics App

  1. Log in to your Wix dashboard
  2. Go to Settings > Integrations & Apps
  3. Search for "Google Analytics" in the Wix App Market
  4. Click Add to Site on the Google Analytics app
  5. Follow the installation prompts

Step 2: Connect Your GA4 Account

  1. Open the Google Analytics app in your dashboard
  2. Click Connect to Google Analytics
  3. Sign in to your Google account
  4. Grant permissions to Wix
  5. Select your GA4 property
  6. Click Connect

Step 3: Configure Settings

  1. Enable Page View Tracking
  2. For Wix Stores, enable Enhanced Ecommerce
  3. Configure event tracking options
  4. Click Save

Method 2: Manual Tracking Code Installation

For custom implementations or specific requirements.

Step 1: Get Your GA4 Measurement ID

  1. Sign in to Google Analytics
  2. Navigate to Admin > Data Streams
  3. Select your web data stream
  4. Copy your Measurement ID (G-XXXXXXXXXX)

Step 2: Add Tracking Code to Wix

  1. In Wix Editor, go to Settings > Custom Code
  2. Click + Add Custom Code
  3. Paste the following in the code box:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-XXXXXXXXXX', {
    'send_page_view': true,
    'cookie_flags': 'SameSite=None;Secure'
  });
</script>
  1. Name it "GA4 Tracking"
  2. Select All pages for placement
  3. Choose Head as load location
  4. Click Apply

Method 3: Wix Velo (For Developers)

Use Velo for advanced custom tracking.

Enable Velo Dev Mode

  1. Open Wix Editor
  2. Click Dev Mode in top menu
  3. Enable Velo development environment
  4. Access code files in the code panel

Add GA4 in Site Code

Create or edit masterPage.js:

import { session } from 'wix-storage';

$w.onReady(function () {
  // Initialize GA4
  if (typeof gtag !== 'undefined') {
    gtag('config', 'G-XXXXXXXXXX', {
      'page_path': $w('#currentPage').name
    });
  }
});

Ecommerce Tracking Configuration

Wix Stores Integration

Automatic ecommerce tracking for Wix Stores.

Enable Enhanced Ecommerce

  1. Install Google Analytics app from Wix App Market
  2. Go to app settings
  3. Enable Enhanced Ecommerce toggle
  4. Select events to track:
    • Product views
    • Add to cart
    • Checkout initiation
    • Purchases
  5. Save settings

Custom Ecommerce Events

Add custom tracking using Velo.

Track Product Views

Add to product page code:

import wixData from 'wix-data';

$w.onReady(function () {
  // Get product data
  $w('#productPage').getProduct().then(product => {
    gtag('event', 'view_item', {
      'currency': product.currency,
      'value': product.price,
      'items': [{
        'item_id': product.sku,
        'item_name': product.name,
        'price': product.price
      }]
    });
  });
});

Track Add to Cart

$w('#addToCartButton').onClick(() => {
  $w('#productPage').getProduct().then(product => {
    gtag('event', 'add_to_cart', {
      'currency': product.currency,
      'value': product.price,
      'items': [{
        'item_id': product.sku,
        'item_name': product.name,
        'price': product.price,
        'quantity': 1
      }]
    });
  });
});

Track Purchases

Add to thank you page:

import wixStoresBackend from 'wix-stores-backend';
import { currentMember } from 'wix-members';

$w.onReady(function () {
  currentMember.getOrders().then(orders => {
    const lastOrder = orders[0];

    gtag('event', 'purchase', {
      'transaction_id': lastOrder.number,
      'value': lastOrder.totals.total,
      'currency': lastOrder.currency,
      'tax': lastOrder.totals.tax,
      'shipping': lastOrder.totals.shipping,
      'items': lastOrder.lineItems.map(item => ({
        'item_id': item.sku,
        'item_name': item.name,
        'price': item.price,
        'quantity': item.quantity
      }))
    });
  });
});

Advanced Event Tracking

Form Submission Tracking

Track Wix Forms submissions:

$w('#contactForm').onWixFormSubmit((event) => {
  gtag('event', 'form_submit', {
    'form_name': 'Contact Form',
    'form_id': event.formName
  });
});

Button Click Tracking

Track button interactions:

$w('#ctaButton').onClick(() => {
  gtag('event', 'cta_click', {
    'button_text': $w('#ctaButton').label,
    'page_name': $w('#currentPage').name
  });
});

Member Login Tracking

Track member authentication:

import { authentication } from 'wix-members';

authentication.onLogin((user) => {
  gtag('event', 'login', {
    'method': 'Wix Members'
  });

  gtag('set', 'user_properties', {
    'member_status': 'logged_in'
  });
});

Scroll Tracking

Monitor page engagement:

let scrolled = false;

$w.onReady(function () {
  $w(window).onScroll(() => {
    const scrollPercentage = ($w(window).scrollY / ($w('Document').height - $w(window).viewportHeight)) * 100;

    if (scrollPercentage > 75 && !scrolled) {
      gtag('event', 'scroll', {
        'percent_scrolled': 75,
        'page_name': $w('#currentPage').name
      });
      scrolled = true;
    }
  });
});

Video Tracking

Track video interactions:

$w('#videoPlayer').onPlay(() => {
  gtag('event', 'video_start', {
    'video_title': $w('#videoPlayer').title
  });
});

$w('#videoPlayer').onEnded(() => {
  gtag('event', 'video_complete', {
    'video_title': $w('#videoPlayer').title
  });
});

Wix Bookings Tracking

Track Appointment Bookings

import wixBookings from 'wix-bookings';

wixBookings.onCheckout((event) => {
  gtag('event', 'appointment_booked', {
    'service_name': event.service.name,
    'service_price': event.service.payment.price,
    'appointment_date': event.booking.startTime
  });
});

Wix Events Tracking

Track Event Registrations

import wixEvents from 'wix-events-backend';

$w('#registerButton').onClick(() => {
  gtag('event', 'event_registration', {
    'event_name': $w('#eventTitle').text,
    'event_date': $w('#eventDate').text
  });
});

Privacy and GDPR Compliance

Implement consent management:

import { local } from 'wix-storage';

$w.onReady(function () {
  // Check if consent given
  const consent = local.getItem('cookie_consent');

  if (consent === 'granted') {
    gtag('consent', 'update', {
      'analytics_storage': 'granted'
    });
  } else {
    gtag('consent', 'default', {
      'analytics_storage': 'denied'
    });
  }
});

// When user accepts cookies
export function acceptCookies() {
  gtag('consent', 'update', {
    'analytics_storage': 'granted'
  });
  local.setItem('cookie_consent', 'granted');
}

Troubleshooting

Tracking Not Working

Issue: No data in GA4 reports

Solutions:

  1. Verify Measurement ID is correct (starts with G-)
  2. Check if Wix Analytics app is properly connected
  3. Ensure custom code is set to load on all pages
  4. Publish site after making changes (tracking won't work in preview)
  5. Test in incognito mode to avoid ad blockers
  6. Check browser console for JavaScript errors

Duplicate Tracking

Issue: Events tracked multiple times

Solutions:

  1. Don't use both Wix Analytics app AND custom code
  2. Check for duplicate code in custom code sections
  3. Verify Velo code isn't duplicating tracking
  4. Remove redundant event handlers
  5. Check third-party apps for conflicts

Ecommerce Events Missing

Issue: Purchase events not appearing

Solutions:

  1. Verify Enhanced Ecommerce is enabled in app settings
  2. Ensure you're on Wix Business & Ecommerce plan
  3. Test with actual purchases (not preview mode)
  4. Check thank you page code is correct
  5. Verify GA4 property has ecommerce enabled

Custom Code Not Loading

Issue: Tracking code doesn't execute

Solutions:

  1. Verify you're on a premium Wix plan
  2. Check code is set to load in Head section
  3. Ensure code is applied to all pages
  4. Publish site (custom code doesn't work in preview)
  5. Check for JavaScript syntax errors
  6. Verify gtag.js script loads before custom events

Velo Code Errors

Issue: Velo tracking code not working

Solutions:

  1. Enable Dev Mode properly
  2. Check imports are correct
  3. Verify API permissions are granted
  4. Test code in Velo console
  5. Check for async/promise handling issues
  6. Review Wix API documentation for updates

App Connection Failed

Issue: Can't connect Google Analytics app

Solutions:

  1. Ensure you're logged into correct Google account
  2. Clear browser cache and cookies
  3. Try in incognito mode
  4. Verify Google account has GA4 property access
  5. Disconnect and reconnect app
  6. Contact Wix support if issue persists

Testing and Verification

Enable Debug Mode

Add to custom code:

<script>
  gtag('config', 'G-XXXXXXXXXX', {
    'debug_mode': true
  });
</script>

Testing Checklist

  1. Publish Site: Always test on published site, not preview
  2. Page Views: Navigate between pages
  3. Ecommerce: Complete test purchase
  4. Forms: Submit test forms
  5. Custom Events: Trigger all tracked interactions
  6. Mobile: Test on mobile devices

Browser Console Testing

// Check if gtag exists
console.log(typeof gtag);

// View dataLayer
console.log(window.dataLayer);

// Fire test event
gtag('event', 'test_event', {'test': 'value'});

GA4 DebugView

  1. Enable debug mode
  2. Open GA4: Admin > DebugView
  3. Browse your Wix site
  4. Verify events appear in real-time
  5. Check event parameters

Velo Console Testing

For Velo implementations:

  1. Open Velo sidebar
  2. Go to Console tab
  3. Add console.log statements
  4. Test code execution
  5. Check for errors

Best Practices

Use Native App When Possible

For most users, the Wix Analytics app provides sufficient functionality without code.

Organize Velo Code

Keep tracking code organized in separate files:

/public
  /analytics
    ga4-config.js
    ecommerce-tracking.js
    event-tracking.js

Test Before Publishing

Always test thoroughly in Wix's preview before publishing changes.

Avoid Tracking in Preview

Prevent development activity from polluting analytics:

if (!$w('#page').preview) {
  // Only track on live site
  gtag('event', 'page_view');
}

Event Naming Consistency

Use clear, consistent event names:

// Good
gtag('event', 'product_click');

// Bad
gtag('event', 'click_prod');

Wix-Specific Considerations

Single Page Application Behavior

Wix uses SPA architecture, so implement virtual page views:

import wixLocation from 'wix-location';

wixLocation.onChange(() => {
  gtag('config', 'G-XXXXXXXXXX', {
    'page_path': wixLocation.path
  });
});

Dynamic Content Loading

Account for Wix's dynamic content:

$w.onReady(function () {
  // Wait for content to load
  setTimeout(() => {
    // Track after content loads
    gtag('event', 'content_loaded');
  }, 1000);
});
// SYS.FOOTER