Wix Tracking Issues
Platform-specific guides for diagnosing and fixing analytics and tracking issues on Wix.
Common Issues
Events Not Firing
Debug why analytics events aren't being captured on Wix.
Wix-Specific Tracking Challenges
Wix's closed platform architecture and Velo development environment create unique tracking scenarios, especially with the Editor vs published site and the restricted code execution environment.
Platform Code Injection Limitations
Wix has strict limitations on where and how custom code can run:
Tracking & Analytics (Settings → Tracking & Analytics):
- Built-in integrations for Google Analytics, Facebook Pixel, Google Ads
- Native integration preferred over custom code
- Limited customization options
- No direct access to tracking code
Custom Code (Settings → Custom Code):
- Head code (loads in
<head>on all pages) - Body - start (loads after
<body>opening tag) - Body - end (loads before
</body>closing tag) - Limited to HTML/JavaScript snippets
- Cannot access Wix site data directly
Velo (formerly Corvid):
- Wix's development platform
- Required for advanced tracking
- Access to Wix APIs and site data
- Can interact with Wix components
- Page code vs Backend code
Embed Code Element:
- Drag-and-drop embed component
- Inline HTML/JavaScript
- Limited to specific page sections
- Isolated from Wix data layer
Code Injection Hierarchy:
Tracking & Analytics (Native Integrations)
↓
Custom Code (Head)
↓
Custom Code (Body - start)
↓
Velo Page Code
↓
Embed Elements (in order)
↓
Custom Code (Body - end)
Editor vs Published Site
Critical Difference:
- Custom code does not run in Wix Editor
- Velo code only runs in Preview and Published modes
- Must use Preview or Publish to test tracking
- Editor shows placeholder elements only
Testing Workflow:
- Add tracking code via Custom Code or Velo
- Click "Preview" to test on preview subdomain
- Check browser console and network requests
- Publish to live site for final verification
- Verify on actual domain
Common Mistakes:
// This WILL NOT work in Wix Editor
console.log('Testing tracking'); // Only visible in Preview/Published
// Must use Preview or Published mode to see output
Wix Velo Development Platform
Velo provides programmatic access to Wix sites but has limitations:
Accessing Site Data:
// In Velo page code (available on specific page)
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(function () {
// Track page view with Wix context
const pagePath = wixLocation.path.join('/');
const pageTitle = wixWindow.title;
// Send to your analytics
if (typeof window.dataLayer !== 'undefined') {
window.dataLayer.push({
'event': 'pageview',
'pagePath': pagePath,
'pageTitle': pageTitle
});
}
console.log('Page loaded:', pagePath, pageTitle);
});
Accessing Wix Stores (E-commerce) Data:
// Velo page code on product page
import wixStores from 'wix-stores';
$w.onReady(async function () {
try {
const product = await wixStores.getCurrentProduct();
// Track product view
window.dataLayer.push({
'event': 'productView',
'ecommerce': {
'detail': {
'products': [{
'id': product._id,
'name': product.name,
'price': product.price,
'brand': product.brand || '',
'category': product.productType
}]
}
}
});
console.log('Product view tracked:', product.name);
} catch (error) {
console.error('Error getting product:', error);
}
});
Cart Events:
// Track add to cart events
import wixStoresCart from 'wix-stores-cart';
$w.onReady(function () {
// Listen for add to cart button clicks
$w('#addToCartButton').onClick(async () => {
try {
const product = await wixStores.getCurrentProduct();
const quantity = $w('#quantityInput').value || 1;
window.dataLayer.push({
'event': 'addToCart',
'ecommerce': {
'add': {
'products': [{
'id': product._id,
'name': product.name,
'price': product.price,
'quantity': quantity
}]
}
}
});
console.log('Add to cart tracked');
} catch (error) {
console.error('Error tracking cart:', error);
}
});
});
Wix Stores (E-commerce) Tracking
Wix Stores requires Velo for comprehensive tracking:
Order Confirmation Tracking:
// On Thank You page (Velo code)
import wixStores from 'wix-stores';
$w.onReady(async function () {
try {
// Get order info from URL parameter
const orderId = wixLocation.query.orderId;
if (orderId) {
// Fetch order details
const order = await wixStores.getOrder(orderId);
// Track purchase
window.dataLayer.push({
'event': 'purchase',
'ecommerce': {
'purchase': {
'actionField': {
'id': order._id,
'revenue': order.totals.total,
'tax': order.totals.tax,
'shipping': order.totals.shipping
},
'products': order.lineItems.map(item => ({
'id': item.productId,
'name': item.name,
'price': item.price,
'quantity': item.quantity
}))
}
}
});
console.log('Purchase tracked:', order._id);
}
} catch (error) {
console.error('Error tracking purchase:', error);
}
});
Alternative - Using Wix Stores Events:
// Backend code (cartChangedEvent.js in Backend folder)
import {cart} from 'wix-stores-backend';
cart.onCartChanged(async (event) => {
// Note: Backend code cannot directly push to dataLayer
// Must use HTTP API to send events to analytics
const cartData = event.cart;
// Send to external analytics API
// (implementation depends on your analytics provider)
console.log('Cart changed:', cartData);
});
Native Integrations vs Custom Code
Wix provides built-in integrations that may conflict with custom tracking:
Built-in Integrations (Settings → Tracking & Analytics):
Common Conflicts:
- Native GA + Custom GTM code = Duplicate tracking
- Multiple pixel installations
- Event naming conflicts
- Data layer overwrites
Check for Native Integrations:
// Check if Wix has loaded native Google Analytics
const hasNativeGA = document.querySelector('script[src*="google-analytics.com/analytics.js"]') ||
document.querySelector('script[src*="google-analytics.com/gtag/js"]');
console.log('Native GA detected:', !!hasNativeGA);
// Check for Facebook Pixel
const hasFbPixel = typeof window.fbq !== 'undefined';
console.log('Facebook Pixel detected:', hasFbPixel);
// List all tracking scripts
const trackingScripts = Array.from(document.querySelectorAll('script[src]'))
.filter(s => s.src.includes('analytics') || s.src.includes('pixel') || s.src.includes('tag'))
.map(s => s.src);
console.log('Tracking scripts:', trackingScripts);
Wix App Market Integrations
Third-party apps from Wix App Market can add tracking:
Common Tracking Apps:
- Advanced Google Analytics
- Facebook Pixel & Conversions API
- Google Tag Manager apps
- Various marketing pixels
Potential Issues:
- Apps may inject duplicate tracking
- App tracking may not be customizable
- Apps may override custom code
- Difficult to debug app-injected code
Audit Installed Apps:
# Via Wix Dashboard:
# Settings → Manage Apps → See all installed apps
# Check each app's settings for tracking features
Comprehensive Diagnostic Checklist
1. Verify Published Site
Critical First Step:
- Code only runs on Preview or Published site
- Not in Editor mode
- Test on preview:
username.wixsite.com/sitename - Then test on custom domain
Validation:
// Add to Custom Code (Body - end) to verify
<script>
console.log('=== Wix Tracking Diagnostic ===');
console.log('URL:', window.location.href);
console.log('Path:', window.location.pathname);
console.log('Is Preview:', window.location.hostname.includes('wixsite.com'));
console.log('User Agent:', navigator.userAgent);
console.log('Loaded at:', new Date().toISOString());
</script>
2. Check Code Injection Settings
Settings → Custom Code:
- Verify code placement (Head vs Body)
- Check for syntax errors
- Ensure code is complete and valid
- No unclosed tags or brackets
Test Script:
<!-- Add to Custom Code (Head) -->
<script>
window.wixTrackingTest = true;
console.log('Wix Head code executed');
</script>
<!-- Add to Custom Code (Body - end) -->
<script>
if (window.wixTrackingTest) {
console.log('Both head and body code working');
} else {
console.error('Head code not working');
}
</script>
3. Test with Velo
If using Velo for advanced tracking:
// Add to Page Code
$w.onReady(function () {
console.log('Velo ready');
console.log('Page ID:', $w('#page').id);
console.log('Wix Location:', wixLocation.url);
// Test dataLayer access
if (window.dataLayer) {
console.log('dataLayer accessible from Velo');
window.dataLayer.push({
'event': 'veloReady',
'pageId': $w('#page').id
});
} else {
console.warn('dataLayer not available');
}
});
4. Inspect Native Integrations
Settings → Tracking & Analytics:
- Check which native integrations are enabled
- Disable duplicates if using custom code
- Note tracking IDs
Verification:
// Check for Wix's built-in tracking
console.log('Native integrations check:');
console.log('GA script:', !!document.querySelector('script[src*="google-analytics.com"]'));
console.log('FB Pixel:', typeof window.fbq);
console.log('GTM:', !!window.google_tag_manager);
5. Monitor Wix Events
// Listen for Wix-specific events
if (window.Wix) {
console.log('Wix object available:', window.Wix);
}
// Monitor for SPA-style navigation (Wix uses client-side routing)
let lastPath = window.location.pathname;
setInterval(function() {
if (window.location.pathname !== lastPath) {
console.log('Navigation detected:', lastPath, '→', window.location.pathname);
lastPath = window.location.pathname;
// Fire pageview for SPA navigation
if (window.dataLayer) {
window.dataLayer.push({
'event': 'pageview',
'page': window.location.pathname
});
}
}
}, 1000);
Browser DevTools Debugging Steps
Network Tab Analysis
Filter for Tracking Requests:
Filter: /collect|/analytics|/tr|/pixel|/track|/gtm
Expected Requests:
google-analytics.com/g/collect - GA4
google-analytics.com/collect - Universal Analytics
facebook.com/tr - Facebook Pixel
googletagmanager.com/gtm.js - GTM
wix.com/_api - Wix internal APIs
Common Issues:
- No tracking requests: Code not running or blocked
- CORS errors: Cross-domain issues
- 403/404 errors: Wrong tracking ID or blocked resource
- Multiple identical requests: Duplicate tracking setup
Console Debugging
// Comprehensive tracking status check
console.log('=== Wix Tracking Debug ===');
console.log('Wix environment:', {
isEditor: window.editorModel !== undefined,
isPreview: window.location.hostname.includes('wixsite.com'),
isPublished: !window.location.hostname.includes('wixsite.com'),
hasVelo: typeof $w !== 'undefined'
});
console.log('Tracking objects:', {
dataLayer: window.dataLayer?.length || 0,
gtag: typeof window.gtag,
ga: typeof window.ga,
fbq: typeof window.fbq,
gtm: !!window.google_tag_manager
});
// Check for errors
window.addEventListener('error', function(e) {
if (e.message.includes('analytics') || e.message.includes('tracking')) {
console.error('Tracking error:', e.message, e.filename, e.lineno);
}
});
Application Tab Storage
// Check tracking cookies
const cookies = document.cookie.split(';');
const trackingCookies = cookies.filter(c =>
c.includes('_ga') || c.includes('_gid') || c.includes('_fb')
);
console.log('Tracking cookies:', trackingCookies);
// Check localStorage
Object.keys(localStorage).forEach(key => {
if (key.includes('ga') || key.includes('analytics')) {
console.log(`localStorage.${key}:`, localStorage.getItem(key));
}
});
Common Symptoms and Causes
| Symptom | Likely Cause | Solution |
|---|---|---|
| Code not executing | Testing in Editor mode | Use Preview or Published site |
| Tracking fires twice | Native integration + Custom code | Disable native integration or remove custom |
| Product data not available | Not using Velo to access Wix Stores | Implement Velo code to get product data |
| Events missing | Velo $w.onReady timing | Ensure code runs after page ready |
| Form submissions not tracked | Wix forms don't expose events | Use Velo onSubmit handlers |
| Navigation not tracked | SPA routing | Implement path change monitoring |
| Purchase tracking fails | No access to order data | Use Velo on Thank You page |
| Different data preview vs live | Different domains | Check domain-specific settings |
| Script blocked by CSP | Wix security policies | Use Wix-approved methods |
| App conflicts | Multiple tracking apps | Audit and remove duplicate apps |
Tag Manager Troubleshooting
Google Tag Manager Setup
Via Custom Code (Settings → Custom Code):
Head Code:
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
Body - Start Code:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
Data Layer with Velo:
// Velo page code to populate dataLayer
$w.onReady(function () {
window.dataLayer = window.dataLayer || [];
// Push page data
window.dataLayer.push({
'event': 'pageview',
'pageType': $w('#page').type || 'page',
'pagePath': wixLocation.path.join('/')
});
console.log('GTM dataLayer initialized');
});
GTM Preview Mode:
- Works on published sites
- Must be on same browser as GTM account
- May require clearing cache
- Test in Preview mode first, then Published
E-commerce Tracking
Product Impressions (Collection Pages)
// Velo code on store collection page
import wixStores from 'wix-stores';
$w.onReady(async function () {
try {
const products = await wixStores.getProducts();
window.dataLayer.push({
'event': 'productImpressions',
'ecommerce': {
'impressions': products.items.map((product, index) => ({
'id': product._id,
'name': product.name,
'price': product.price,
'position': index + 1
}))
}
});
} catch (error) {
console.error('Error loading products:', error);
}
});
Checkout Tracking
// On cart/checkout page
import wixStoresCart from 'wix-stores-cart';
$w.onReady(async function () {
try {
const cart = await wixStoresCart.getCurrentCart();
window.dataLayer.push({
'event': 'checkout',
'ecommerce': {
'checkout': {
'actionField': {'step': 1},
'products': cart.lineItems.map(item => ({
'id': item.productId,
'name': item.name,
'price': item.price,
'quantity': item.quantity
}))
}
}
});
} catch (error) {
console.error('Error tracking checkout:', error);
}
});
Cookie and Consent Management
Wix Cookie Consent
Wix has built-in GDPR compliance tools:
Settings → Cookie Consent:
- Enable cookie banner
- Customize cookie policy
- Configure which cookies require consent
Conditional Tracking Based on Consent:
// Check Wix consent status (if using Wix cookie consent)
function checkWixConsent() {
// Wix stores consent in a cookie
const consentCookie = document.cookie.match(/consentPolicyApproved=([^;]+)/);
if (consentCookie && consentCookie[1] === '1') {
return true;
}
return false;
}
// Load tracking only if consent given
if (checkWixConsent()) {
// Initialize tracking
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
} else {
console.log('Waiting for cookie consent');
}
Google Consent Mode:
// Set default consent state
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied'
});
// Update when Wix consent is given
if (checkWixConsent()) {
gtag('consent', 'update', {
'ad_storage': 'granted',
'analytics_storage': 'granted',
'ad_user_data': 'granted',
'ad_personalization': 'granted'
});
}
When to Contact Support
Contact Wix Support When:
Platform-Level Issues:
- Custom Code not saving
- Velo code not executing
- Native integrations not working
- Site publishing issues
- Wix Stores checkout errors
Provide to Wix:
- Site URL (both preview and published)
- Screenshots of Custom Code/Velo settings
- Browser console errors
- Specific pages with issues
- Steps to reproduce
Contact Analytics Vendor When:
- Events firing but not in reports
- Data attribution errors
- Tag configuration issues
- API integration problems
Provide to Vendor:
- Network tab showing tracking requests
- Console logs with event data
- Property/tracking IDs
- Example URLs
Contact Velo Developer When:
- Complex Wix Stores tracking
- Advanced form tracking
- Custom Wix app integration
- Member area tracking
- Database integrations
Provide to Developer:
- Site access (collaborator invite)
- Current code implementation
- Desired tracking behavior
- Console errors
- API documentation needs
General Fixes
For universal tracking concepts, see the Global Tracking Issues Hub.