Google Tag Manager (GTM) provides centralized management for all tracking tags on your Ecwid store, making it easier to add, update, and manage analytics without editing code.
Why Use GTM with Ecwid?
Benefits
- Centralized management: All tracking tags in one place
- No code edits: Update tracking without modifying store code
- Version control: Track changes and roll back if needed
- Built-in testing: Preview mode before publishing
- Better performance: Single container loads all tags efficiently
- Team collaboration: Multiple users can manage tags
- Works with host platform: Unified tracking across host and Ecwid widget
GTM vs Direct Implementation
| Feature | GTM | Direct Code |
|---|---|---|
| Ease of updates | Easy (no code) | Hard (edit code) |
| Multiple tags | Single container | Multiple scripts |
| Testing | Built-in preview | Manual testing |
| Version control | Yes | No |
| Team access | Yes | Limited |
| Performance | Optimized | Can be slow |
| Learning curve | Medium | Easy |
Recommendation: Use GTM for most stores unless you have only one or two simple tracking tags.
Prerequisites
- Google Tag Manager account (free)
- Access to Ecwid Control Panel
- Basic understanding of GTM concepts
Setup Overview
- Create GTM account and container
- Install GTM on Ecwid
- Configure Ecwid data layer events
- Add tracking tags (GA4, Meta Pixel, etc.)
- Test with Preview mode
- Publish container
Step 1: Create GTM Account and Container
Create Account
Go to tagmanager.google.com
Click "Create Account"
Account Setup:
- Account Name: Your company name
- Country: Select your country
- Check data sharing settings (optional)
Container Setup:
- Container Name: Your store name
- Target Platform: Web
Accept Terms of Service
Copy Container Code
You'll see two code snippets:
- Head snippet (goes in
<head>) - Body snippet (goes in
<body>)
Copy both for next step.
- Head snippet (goes in
GTM Container ID
Your container ID format: GTM-XXXXXXX
You'll need this ID for installation.
Step 2: Install GTM on Ecwid
There are two scenarios depending on your host platform.
Scenario A: Host Platform DOES NOT Have GTM
Install GTM in Ecwid's custom code section.
Access Custom Code
- Log in to my.ecwid.com
- Go to Settings → General → Tracking & Analytics
- Scroll to Custom JavaScript Code section
- Click Add custom code
Add GTM Head Code
Paste this 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 --> <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) -->Replace
GTM-XXXXXXXwith your actual container ID.Save
Click Save button.
Scenario B: Host Platform ALREADY Has GTM
Use your existing GTM container for both host and Ecwid.
No additional installation needed - your existing GTM container will automatically work with the Ecwid widget if it's on the same page.
Note: If host platform GTM is NOT on same page as Ecwid widget (e.g., Ecwid on subdomain), install GTM separately in Ecwid using Scenario A steps.
Verification
Check if GTM is installed correctly:
Visit your store
Open browser console (F12)
Run command:
console.log(window.google_tag_manager);Expected output: Object with your container ID
If returns
undefined, GTM is not loaded correctly.
Step 3: Configure Data Layer
Ecwid automatically pushes ecommerce events to the data layer. Verify it's working:
Check Data Layer
Visit product page
Open console (F12)
View data layer:
console.table(window.dataLayer);Look for Ecwid events:
product_viewedcart_changed- etc.
If Data Layer is Empty
Ecwid should populate data layer automatically. If not:
- Check Ecwid version: Update to latest
- Check JavaScript errors: Fix any console errors
- Manual data layer setup: See Data Layer documentation
Step 4: Add Tracking Tags
Now add your tracking tags in GTM.
Example: Add GA4 Configuration Tag
In GTM, go to Tags → New
Tag Configuration:
- Click Tag Configuration
- Select Google Analytics: GA4 Configuration
Configuration:
- Measurement ID: Enter your GA4 ID (G-XXXXXXXXXX)
- Configuration Settings: Add any custom parameters
Triggering:
- Click Triggering
- Select All Pages
Name and Save:
- Name: "GA4 - Configuration"
- Click Save
Example: Add GA4 Event Tag
Tags → New
Tag Configuration:
- Select Google Analytics: GA4 Event
Configuration:
- Configuration Tag: Select "GA4 - Configuration"
- Event Name:
view_item - Event Parameters: Add parameters from data layer
Triggering:
- Create trigger for Ecwid product view event
- Type: Custom Event
- Event name:
product_viewed
Save as "GA4 - View Item"
See Data Layer documentation for complete event mapping.
Example: Add Meta Pixel Base Tag
Tags → New
Tag Configuration:
- Select Custom HTML
HTML:
<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', '1234567890123456'); fbq('track', 'PageView'); </script>Replace
1234567890123456with your Pixel ID.Triggering: All Pages
Save as "Meta Pixel - Base Code"
Step 5: Create Variables
Create GTM variables to extract Ecwid data.
Example: Product ID Variable
Variables → New
Variable Configuration:
- Type: Data Layer Variable
- Data Layer Variable Name:
ecommerce.detail.products.0.id - Data Layer Version: Version 2
Name:
DLV - Product IDSave
Example: Cart Total Variable
Variables → New
Variable Configuration:
- Type: Data Layer Variable
- Data Layer Variable Name:
ecommerce.cart.total
Name:
DLV - Cart TotalSave
See Data Layer Variables for complete list.
Step 6: Create Triggers
Create triggers for Ecwid-specific events.
Example: Product Viewed Trigger
Triggers → New
Trigger Configuration:
- Type: Custom Event
- Event name:
product_viewed
Name:
Ecwid - Product ViewedSave
Example: Purchase Trigger
Triggers → New
Trigger Configuration:
- Type: Custom Event
- Event name:
order_placed
Name:
Ecwid - Order PlacedSave
Common Ecwid Triggers
Create triggers for:
product_viewed- Product detail viewcart_changed- Cart updatedcheckout_started- Checkout initiatedorder_placed- Purchase completed
Step 7: Test with Preview Mode
Always test before publishing.
Enable Preview Mode
In GTM, click "Preview" (top right)
Enter your store URL
Click "Connect"
Test Flow
Navigate to store - Tag Assistant opens
View product - Check product_viewed event fires
Add to cart - Check cart_changed event fires
Start checkout - Check checkout_started fires
Complete test order - Check order_placed fires
Verify in Tag Assistant
For each event:
- Tags Fired: Should show your tags
- Data Layer: Should show Ecwid data
- Variables: Should populate correctly
Debug Issues
Tag not firing:
- Check trigger conditions
- Verify event name matches exactly
- Check for JavaScript errors
Variable undefined:
- Check data layer path
- Verify event has fired
- Check variable name
Step 8: Publish Container
Once testing is complete, publish your container.
Click "Submit" (top right)
Version Name: E.g., "Initial Ecwid Setup"
Version Description: Describe changes
Publish
Post-Publish Verification
Clear browser cache
Visit store in incognito mode
Verify tracking works:
- GA4 Realtime reports
- Meta Events Manager
- Other analytics platforms
Monitor for 24-48 hours for any issues
Host Platform Integration
WordPress
Option 1: GTM Plugin
Use Google Tag Manager for WordPress:
- Install plugin
- Enter GTM Container ID
- Plugin adds GTM to all pages (including Ecwid widget)
Option 2: Manual
Add GTM to theme header.php and footer.php.
Wix
Wix has built-in GTM support:
- Settings → Tracking & Analytics
- Google Tag Manager
- Enter Container ID
- Works automatically with Ecwid widget
Squarespace
Add GTM via code injection:
- Settings → Advanced → Code Injection
- Header: Add GTM head code
- Footer: Add GTM body code
Custom HTML Sites
Add GTM code directly to your HTML:
<!DOCTYPE html>
<html>
<head>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){...})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"...></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<!-- Your Ecwid store widget -->
<div id="my-store-123456"></div>
</body>
</html>
Advanced Configuration
Multiple Containers
Use separate containers for different purposes:
- Master Container: Main tracking (GA4, Meta Pixel)
- Testing Container: For testing new tags
- Partner Container: For agency/partner access
Install multiple containers:
// Load multiple containers
gtag('js', new Date());
gtag('config', 'GTM-XXXXXXX'); // Container 1
gtag('config', 'GTM-YYYYYYY'); // Container 2
Custom Data Layer Variables
Push custom Ecwid data to data layer:
Ecwid.OnAPILoaded.add(function() {
Ecwid.OnPageLoad.add(function(page) {
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'event': 'ecwid_page_load',
'ecwid_page_type': page.type,
'ecwid_page_id': page.productId || page.categoryId || null
});
});
});
Add this to Ecwid Custom JavaScript Code section.
Server-Side GTM
For advanced tracking and privacy compliance:
- Set up Server-Side GTM container in Google Cloud
- Configure Ecwid webhooks to send server-side events
- Route events through server-side GTM
- Better data privacy and tracking accuracy
See Server-Side GTM documentation for setup.
Workspace and Version Control
Create Workspace
For team collaboration:
- Workspaces → Create
- Name workspace: E.g., "Holiday Campaign"
- Make changes in workspace
- Submit and merge when ready
Version History
View and restore previous versions:
- Versions (sidebar)
- View version details
- Restore if needed
Troubleshooting
GTM Not Loading
Check:
- Container ID correct (GTM-XXXXXXX)
- No JavaScript errors in console
- Code in correct location
Test:
console.log(window.google_tag_manager);
Should show GTM object with your container ID.
Tags Not Firing
Common causes:
- Container not published
- Trigger conditions not met
- JavaScript errors blocking execution
- Event name misspelled
Debug:
- Use Preview mode
- Check Tag Assistant
- Verify data layer events
Data Layer Empty
Causes:
- Ecwid not loaded yet
- JavaScript errors
- Old Ecwid version
Fix:
- Update Ecwid to latest version
- Check console for errors
- Manually implement data layer (see Data Layer guide)
Duplicate Events
Cause: Multiple GTM containers or duplicate tracking implementations.
Fix:
- Check for multiple GTM containers
- Verify host platform doesn't also have tracking
- Remove duplicate implementations
Best Practices
1. Use Descriptive Naming
Good names:
- Tag: "GA4 - View Item Event"
- Trigger: "Ecwid - Product Viewed"
- Variable: "DLV - Product ID"
Bad names:
- Tag: "Tag 1"
- Trigger: "Trigger"
- Variable: "Var"
2. Add Descriptions
Document what each tag, trigger, and variable does.
3. Use Folders
Organize tags into folders:
- Google Analytics
- Meta Pixel
- Custom Events
- Utilities
4. Test Before Publishing
Always use Preview mode before publishing changes.
5. Version Naming
Use clear version names:
- "Initial Setup - GA4 and Meta Pixel"
- "Add Custom Events for Holiday Campaign"
- "Fix Purchase Event Duplicate Tracking"
6. Limit Users
Only give GTM access to team members who need it.
7. Regular Audits
Quarterly:
- Remove unused tags
- Check for deprecated tags
- Update tag configurations
- Review triggers
Next Steps
- Ecwid Data Layer Structure - Complete data layer reference
- GA4 Setup - Configure GA4 in GTM
- Meta Pixel Setup - Configure Meta Pixel in GTM
For general GTM concepts, see Google Tag Manager Guide.