Google Tag Manager Setup on Wix | Blue Frog Docs

Google Tag Manager Setup on Wix

Complete guide to installing and configuring Google Tag Manager on Wix websites.

Google Tag Manager Setup on Wix

Google Tag Manager (GTM) is the recommended approach for managing multiple marketing tags on Wix. This guide covers installation methods, Wix-specific configuration, and best practices.

Why Use GTM on Wix?

Advantages

  1. Centralized tag management - Deploy and update tags without editing Wix code
  2. Version control - Track changes and roll back if needed
  3. Preview mode - Test tags before publishing
  4. Multiple tags in one container - GA4, Meta Pixel, ads pixels, etc.
  5. Advanced tracking - Custom triggers and variables
  6. Reduced code bloat - One GTM script instead of multiple vendor scripts

Limitations on Wix

  1. No native Wix data layer - Must build your own with Velo
  2. SPA navigation challenges - Wix AJAX transitions require special handling
  3. Limited DOM access - Wix's structure makes some selectors difficult
  4. Custom code restrictions - Must use Premium Wix plan
  5. No staging environment - Testing must be done carefully in production

Prerequisites

  • Wix Premium plan (required for custom code)
  • Google Tag Manager account (free)
  • GTM Container ID (format: GTM-XXXXXXX)

This is the standard GTM installation for Wix.

Step 1: Create GTM Container

  1. Go to Google Tag Manager
  2. Create a new container or select existing
  3. Copy your Container ID (GTM-XXXXXXX)

Step 2: Add GTM to Wix Header

  1. Wix DashboardSettingsCustom Code
  2. Click + Add Custom Code
  3. Name: "Google Tag Manager - Head"
  4. Paste the following 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-XXXXXXX');</script>
<!-- End Google Tag Manager -->
  1. Configure:

    • Load code on: All pages
    • Place code in: Head
    • Load code once: ✅ Checked
  2. Click Apply

GTM recommends a <noscript> fallback in the <body>. However, Wix does not support body code injection in the Custom Code interface.

Workaround:

Add this to a site-wide footer code area or embed in a custom element:

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

Note: This is less critical for Wix since JavaScript is generally required for Wix sites to function.

Step 4: Publish Your Wix Site

GTM will not load until you publish changes.

Step 5: Verify Installation

  1. Visit your live Wix site

  2. Open GTM Preview Mode:

    • In GTM, click Preview
    • Enter your Wix site URL
    • Click Connect
  3. Verify GTM loads:

    • You should see "Connected" in GTM debugger
    • Check Tag Assistant tab for firing tags

Installation Method 2: Marketing Integrations (Limited)

Wix occasionally offers GTM through Marketing Integrations, but availability varies.

Check: Dashboard → Marketing & SEO → Marketing Integrations

If available, follow on-screen instructions. However, this method provides less flexibility than custom code installation.

Wix-Specific GTM Configuration

Handling Wix's SPA Navigation

Wix uses AJAX for smooth page transitions, which means:

  • Traditional pageviews may not fire on navigation
  • GTM's default triggers may miss route changes

Solution: Implement history change detection.

Step 1: Create Custom HTML Tag in GTM

Tag name: "History Change Listener"

Tag type: Custom HTML

Code:

<script>
(function() {
  // Store original pushState and replaceState
  var originalPushState = history.pushState;
  var originalReplaceState = history.replaceState;

  // Override pushState
  history.pushState = function() {
    originalPushState.apply(history, arguments);
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event': 'wix.page.navigation'
    });
  };

  // Override replaceState
  history.replaceState = function() {
    originalReplaceState.apply(history, arguments);
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event': 'wix.page.navigation'
    });
  };

  // Also listen for popstate (back/forward buttons)
  window.addEventListener('popstate', function() {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event': 'wix.page.navigation'
    });
  });
})();
</script>

Trigger: All Pages (Page View)

Step 2: Create Custom Event Trigger

Trigger name: "Wix Page Navigation"

Trigger type: Custom Event

Event name: wix.page.navigation

This trigger fires on: All Custom Events

Step 3: Configure GA4 Tag for Virtual Pageviews

If using GA4 through GTM:

Tag name: "GA4 - Virtual Pageview"

Tag type: GA4 Event

Configuration Tag: Your GA4 Configuration tag

Event Name: page_view

Trigger: Wix Page Navigation (created above)

Important: Set your main GA4 config tag to trigger ONLY on Page View (not on All Pages), or you'll get duplicate pageviews.

Setting Up Variables for Wix

Create these User-Defined Variables in GTM for easier tracking:

Page Path Variable

Variable name: "Page Path - Clean"

Variable type: JavaScript Variable

Code:

function() {
  return window.location.pathname;
}

Page Title Variable

Variable name: "Page Title"

Variable type: JavaScript Variable

Code:

function() {
  return document.title;
}

Site Language Variable

Variable name: "Site Language"

Variable type: JavaScript Variable

Code:

function() {
  return document.documentElement.lang || 'en';
}

For GDPR compliance, configure Google Consent Mode:

Tag name: "Consent Mode - Default State"

Tag type: Custom HTML

Code:

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

gtag('consent', 'default', {
  'analytics_storage': 'denied',
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'wait_for_update': 500
});
</script>

Trigger: Consent Initialization - All Pages

Tag firing priority: 100 (fires before other tags)

Tag name: "Consent Mode - Update on Accept"

Tag type: Custom HTML

Code:

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

gtag('consent', 'update', {
  'analytics_storage': 'granted',
  'ad_storage': 'granted',
  'ad_user_data': 'granted',
  'ad_personalization': 'granted'
});
</script>

Trigger: Custom Event - consent.granted

Fire this trigger when user accepts cookies (see GTM Data Layer guide).

Common Tags to Deploy via GTM

1. Google Analytics 4

Tag type: Google Analytics: GA4 Configuration

Measurement ID: G-XXXXXXXXXX

Configuration:

  • Send page_view event: ✅ (if not handling with custom trigger)
  • Configure tag settings as needed

Trigger:

  • Page View (for initial pageview)
  • Wix Page Navigation (for virtual pageviews)

2. Meta Pixel (Facebook Pixel)

Tag type: Custom HTML

Code:

<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
</script>

Trigger: All Pages + Wix Page Navigation

3. Google Ads Conversion Tracking

Tag type: Google Ads Conversion Tracking

Conversion ID: AW-XXXXXXXXXX

Conversion Label: Your conversion label

Trigger: Custom event (e.g., form submission, purchase)

Debugging GTM on Wix

Use GTM Preview Mode

  1. In GTM, click Preview
  2. Enter your Wix site URL
  3. Click Connect
  4. New tab opens with debugger attached
  5. Navigate your site and check which tags fire

Common Debug Checks

  • Tags firing on pageview: Check Summary tab
  • Variables populating correctly: Check Variables tab
  • Triggers activating: Check Triggers tab
  • Data layer events: Check Data Layer tab

Browser Console Debugging

Check data layer manually:

console.log(window.dataLayer);

Manually push test events:

dataLayer.push({
  'event': 'test_event',
  'customParam': 'test value'
});

Testing Before Publishing GTM Changes

1. Preview Mode (Required)

Always test in Preview mode before publishing GTM changes.

2. QA Checklist

  • GTM container loads on all pages
  • Page views track correctly (including SPA navigation)
  • Custom events fire as expected
  • Variables populate with correct data
  • No JavaScript errors in console
  • No duplicate tracking (check network tab)
  • Tags respect consent mode
  • Mobile testing (responsive behavior)

3. Publish with Version Notes

When publishing:

  • Add descriptive version name: "Added GA4 ecommerce tracking"
  • Add version description: List all changes
  • This creates version history for rollbacks

Common Wix + GTM Issues

Issue Cause Solution
GTM not loading Custom code not published Publish Wix site after adding GTM code
Duplicate pageviews Multiple pageview tags Use ONLY Page View OR custom SPA trigger, not both
Tags not firing on navigation SPA not detected Implement history change listener (see above)
Variables return undefined Timing issue - DOM not ready Use GTM's built-in variables or add delay
Preview mode won't connect Browser blocking cookies Disable ad blockers, use incognito mode
Tags fire twice GTM installed multiple times Check Custom Code and Marketing Integrations

Performance Considerations

Minimize Tag Load Impact

  1. Use async tags when possible
  2. Consolidate tags through GTM instead of multiple direct implementations
  3. Set firing priorities for tags that must load in order
  4. Monitor Core Web Vitals after adding tags (see LCP troubleshooting)

Wix Turbo Compatibility

GTM works with Wix Turbo (Wix's performance optimization). However:

  • Test thoroughly after enabling Turbo
  • Verify all tags still fire correctly
  • Check for timing issues with custom HTML tags

GTM Workspace Best Practices

  1. Use separate workspaces for major changes
  2. Name tags clearly: "GA4 - Pageview", "Meta Pixel - Add to Cart"
  3. Document triggers: Add notes explaining custom triggers
  4. Test before publishing: Always use Preview mode
  5. Regular container exports: Backup your GTM config
  6. Limit container access: Only give access to trained team members

Wix Plan Requirements

Feature Wix Plan Required
Custom Code (for GTM) Premium plans or higher
Full GTM functionality Any premium plan
Velo (for data layer) Premium + Velo enabled
Wix Studio (advanced) Wix Studio plan

Next Steps

Additional Resources

// SYS.FOOTER