Magento Tracking Issues
Platform-specific guides for diagnosing and fixing analytics and tracking issues on Magento.
Common Issues
Events Not Firing
Debug why analytics events aren't being captured on Magento.
Overview of Magento Tracking Issues
Magento's (now Adobe Commerce) complex architecture presents unique analytics challenges. The platform's extensive caching layers, Full Page Cache (FPC), Varnish integration, block-level rendering, and modular structure require specialized tracking approaches. Understanding Magento's layout XML, PHP rendering, and JavaScript compilation is essential for effective troubleshooting.
Magento-Specific Tracking Challenges
Magento Architecture Complexity
Magento's multi-layered architecture affects tracking:
- Full Page Cache (FPC) - Built-in page caching serves static HTML
- Varnish integration - Enterprise-level caching prevents dynamic tracking
- Block caching - Individual page components cached separately
- Layout XML - Template structure defined in XML affects code placement
- Module dependencies - Tracking modules may conflict with other extensions
- Multi-store setup - Different stores require different tracking codes
Version-Specific Differences
Magento 1 vs Magento 2/Adobe Commerce have significant differences:
Magento 1 (EOL):
- Prototype.js framework conflicts
- Older template structure
- Different module system
- Limited developer support
Magento 2 / Adobe Commerce:
- RequireJS for JavaScript dependencies
- UI components framework
- Knockout.js for dynamic UIs
- Modern template structure
- Page Builder for content management
Ecommerce Data Layer Challenges
Enhanced ecommerce tracking requires specific data:
- Product impressions - Category pages, search results
- Product clicks - From listings to product detail pages
- Product detail views - Individual product pages
- Add to cart - Cart additions with product data
- Checkout steps - Multi-step checkout process
- Purchase completion - Transaction data with items
- Promotions - Internal promotions and banners
Theme and Extension Conflicts
Magento's extension ecosystem creates conflicts:
- Multiple analytics extensions - Google Analytics, Facebook Pixel, etc.
- Custom themes - Override tracking code placement
- Page builders - Drag-and-drop builders alter HTML structure
- Checkout extensions - One-step checkout modules change tracking flow
- JavaScript minification - Merge and minify breaks inline scripts
- CSS/JS bundling - RequireJS bundling affects script load order
Diagnostic Checklist for Tracking Issues
Work through these steps systematically:
1. Verify Module Installation
# Magento 2 CLI commands
# Check if module is installed and enabled
php bin/magento module:status | grep -i google
php bin/magento module:status | grep -i analytics
php bin/magento module:status | grep -i tag
# List all enabled modules
php bin/magento module:status --enabled
# Check module configuration
php bin/magento config:show google/analytics
2. Check Tracking Code in Admin
Navigate to:
- Magento 2: Stores > Configuration > Sales > Google API > Google Analytics
- Check "Enable" is set to "Yes"
- Verify Account Number/Measurement ID
- Check Account Type (Universal Analytics vs GA4)
3. Inspect Template Files
# Find tracking code in theme templates
grep -r "googletagmanager\|analytics\|gtag" app/design/frontend/
# Check for tracking in layout XML
grep -r "google_analytics\|gtm" app/design/frontend/
# Find head/footer templates
find app/design/frontend/ -name "head.phtml"
find app/design/frontend/ -name "footer.phtml"
4. Check Cache Status
# Check cache status
php bin/magento cache:status
# Flush all caches
php bin/magento cache:flush
# Clean cache
php bin/magento cache:clean
# Disable cache for testing (DEVELOPMENT ONLY)
php bin/magento cache:disable full_page
php bin/magento cache:disable block_html
5. Test JavaScript Console
// Open Console (F12) and check:
// Check if tracking scripts loaded
console.log('GTM loaded:', typeof dataLayer !== 'undefined');
console.log('GA loaded:', typeof gtag !== 'undefined' || typeof ga !== 'undefined');
// Check RequireJS (Magento 2)
console.log('RequireJS loaded:', typeof require !== 'undefined');
// Check for Magento-specific objects
console.log('Magento customer data:', typeof customerData !== 'undefined');
// Check checkout
if (typeof window.checkout !== 'undefined') {
console.log('Checkout object:', window.checkout);
}
Verifying Tracking Code Loads Correctly
Method 1: Admin Configuration Check
Magento 2: Stores > Configuration > Sales > Google API
Verify:
- Google Analytics is enabled
- Correct tracking ID/measurement ID
- Account type matches your property
- Content experiments enabled (if using)
Method 2: View Source Inspection
<!-- GTM should appear in <head> -->
<script>
(function(w,d,s,l,i){...})(window,document,'script','dataLayer','GTM-XXXXX');
</script>
<!-- GA4 or Universal Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXX');
</script>
<!-- Check for ecommerce data in JSON -->
<script type="text/x-magento-init">
{
"*": {
"Magento_GoogleAnalytics/js/google-analytics": {...}
}
}
</script>
Method 3: Browser Console Verification
// Open Console (F12) and run:
// Check dataLayer
if (typeof dataLayer !== 'undefined') {
console.log('✓ dataLayer exists:', dataLayer);
console.log(' Items in dataLayer:', dataLayer.length);
// Look for ecommerce data
var ecommerceEvents = dataLayer.filter(item => item.ecommerce);
console.log(' Ecommerce events:', ecommerceEvents);
} else {
console.error('✗ dataLayer not found');
}
// Check Magento customer data
require(['Magento_Customer/js/customer-data'], function(customerData) {
console.log('Customer sections:', customerData.getExpiredSectionNames());
var cart = customerData.get('cart');
console.log('Cart data:', cart());
});
// Check for Google Analytics
if (typeof gtag !== 'undefined') {
console.log('✓ GA4 (gtag) loaded');
} else if (typeof ga !== 'undefined') {
console.log('✓ Universal Analytics loaded');
} else {
console.error('✗ No Google Analytics found');
}
Method 4: Network Tab Verification
- Open DevTools Network tab (F12)
- Filter by "gtm" or "analytics" or "collect"
- Add to cart or navigate pages
- Look for:
gtm.js- Google Tag Manager containeranalytics.jsorgtag/js- Google Analyticscollect- Analytics hit with ecommerce data
Verify payload includes:
- Product ID, name, price
- Currency code
- Quantity
- Transaction ID (on purchase)
Browser Developer Tools Debugging Guide
Console Debugging for Magento 2
// Enable RequireJS logging
require.config({
config: {
'mixins': {
'Magento_GoogleAnalytics/js/google-analytics': {
'Your_Module/js/google-analytics-mixin': true
}
}
}
});
// Monitor dataLayer pushes
(function() {
if (typeof dataLayer === 'undefined') {
console.error('dataLayer not initialized');
window.dataLayer = [];
}
var originalPush = dataLayer.push;
dataLayer.push = function() {
console.log('[dataLayer.push]', arguments[0]);
return originalPush.apply(dataLayer, arguments);
};
})();
// Debug cart data
require(['Magento_Customer/js/customer-data'], function(customerData) {
var cart = customerData.get('cart');
cart.subscribe(function(cartData) {
console.log('Cart updated:', cartData);
if (typeof dataLayer !== 'undefined' && cartData.items && cartData.items.length > 0) {
// Check if cart data properly structured
console.log('Cart items for tracking:', cartData.items);
}
});
});
// Check checkout step
require(['Magento_Checkout/js/model/quote'], function(quote) {
console.log('Current quote:', quote);
console.log('Quote items:', quote.getItems());
});
Magento-Specific Event Tracking
// Track AJAX cart additions
require(['jquery'], function($) {
$(document).on('ajax:addToCart', function(event, data) {
console.log('Product added to cart:', data);
if (typeof dataLayer !== 'undefined' && data.productIds) {
// Note: You'll need product data from page
dataLayer.push({
'event': 'addToCart',
'ecommerce': {
'currencyCode': data.currencyCode || 'USD',
'add': {
'products': [{
'id': data.productIds[0],
'name': data.productName,
'price': data.productPrice,
'quantity': data.qty || 1
}]
}
}
});
}
});
});
// Track checkout steps
require(['Magento_Checkout/js/model/step-navigator'], function(stepNavigator) {
stepNavigator.steps.subscribe(function(steps) {
console.log('Checkout steps:', steps);
});
});
Network Tab Debugging
Filter for Magento-specific requests:
customer/section/load
checkout/cart/add
sales/order/success
gtm
analytics
collect
Check request payloads for:
- Section data (cart, customer, checkout)
- Product information
- Order/transaction data
- Custom dimensions
Application Tab (Local Storage)
Magento 2 uses localStorage for customer sections:
// Inspect customer data in localStorage
var sectionData = localStorage.getItem('mage-cache-storage');
if (sectionData) {
console.log('Customer sections:', JSON.parse(sectionData));
}
// Check section timestamps
var sectionsTimestamp = localStorage.getItem('mage-cache-sessionstorage');
if (sectionsTimestamp) {
console.log('Section timestamps:', JSON.parse(sectionsTimestamp));
}
Common Symptoms and Their Causes
| Symptom | Likely Cause | Solution |
|---|---|---|
| No tracking on any page | Module disabled or tracking ID missing | Enable Google Analytics in Admin, add tracking ID |
| Tracking works without FPC, fails with FPC | Cached pages don't include dynamic data | Use AJAX for dynamic ecommerce data or disable block cache |
| Product impressions not firing | Data not in dataLayer on page load | Add product data in layout XML or use JavaScript |
| Add to cart events missing | AJAX cart additions not tracked | Listen for cart section update events |
| Duplicate page views | Multiple analytics modules enabled | Disable conflicting extensions |
| Checkout steps not tracked | No listeners on checkout steps | Implement step tracking in checkout |
| Purchase data incomplete | Order success page cached | Make order data block non-cacheable |
| Random JavaScript errors | RequireJS dependency issues | Check module dependencies, clear static files |
| Tracking works on desktop, not mobile | Responsive theme JavaScript issues | Test mobile-specific templates |
| Different data per store view | Wrong tracking code per store | Configure tracking per store view |
| Varnish serving cached tracking | Varnish caching HTML with old data | Configure Varnish to not cache analytics requests |
| Product data shows [object Object] | JSON not properly parsed | Check dataLayer structure and parsing |
Tag Manager Troubleshooting for Magento
GTM Installation in Magento
Method 1: Via Extension
Install GTM extension from Marketplace:
composer require vendor/module-gtm
php bin/magento module:enable Vendor_Gtm
php bin/magento setup:upgrade
php bin/magento cache:flush
Method 2: Manual Template Addition
Add to app/design/frontend/[Vendor]/[Theme]/Magento_Theme/templates/html/head.phtml:
<!-- 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 -->
Add to app/design/frontend/[Vendor]/[Theme]/Magento_Theme/templates/html/body.phtml:
<!-- 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) -->
DataLayer Configuration for Magento
Product Page DataLayer:
<!-- In catalog/product/view.phtml or custom block -->
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'ecommerce': {
'detail': {
'products': [{
'id': '<?= $block->escapeJs($product->getSku()) ?>',
'name': '<?= $block->escapeJs($product->getName()) ?>',
'price': '<?= $product->getFinalPrice() ?>',
'brand': '<?= $block->escapeJs($product->getAttributeText('manufacturer')) ?>',
'category': '<?= $block->escapeJs($categoryName) ?>',
'variant': '<?= $block->escapeJs($product->getAttributeText('color')) ?>'
}]
}
},
'event': 'productDetail'
});
</script>
Order Success DataLayer:
<!-- In checkout/success.phtml or custom block -->
<?php
$order = $block->getOrder();
$items = $order->getAllVisibleItems();
?>
<script>
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': '<?= $block->escapeJs($order->getIncrementId()) ?>',
'revenue': '<?= $order->getGrandTotal() ?>',
'tax': '<?= $order->getTaxAmount() ?>',
'shipping': '<?= $order->getShippingAmount() ?>',
'coupon': '<?= $block->escapeJs($order->getCouponCode()) ?>'
},
'products': [
<?php foreach ($items as $item): ?>
{
'id': '<?= $block->escapeJs($item->getSku()) ?>',
'name': '<?= $block->escapeJs($item->getName()) ?>',
'price': '<?= $item->getPrice() ?>',
'quantity': <?= $item->getQtyOrdered() ?>
},
<?php endforeach; ?>
]
}
},
'event': 'purchase'
});
</script>
GTM Preview Mode Issues
Problem: Preview mode doesn't connect in Magento
Solutions:
- Flush Magento caches:
php bin/magento cache:flush
Disable JavaScript bundling/minification:
- Stores > Configuration > Developer > JavaScript Settings
- Set "Merge JavaScript Files" to "No"
- Set "Enable JavaScript Bundling" to "No"
- Set "Minify JavaScript Files" to "No"
Check Content Security Policy:
// Add to CSP whitelist if using Magento_Csp
// app/code/Vendor/Module/etc/csp_whitelist.xml
<?xml version="1.0"?>
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
<policies>
<policy id="script-src">
<values>
<value id="google-tag-manager" type="host">*.googletagmanager.com</value>
<value id="google-analytics" type="host">*.google-analytics.com</value>
</values>
</policy>
</policies>
</csp_whitelist>
Enhanced Ecommerce Tracking Troubleshooting
Product Impressions Tracking
Issue: Product impressions not tracking on category pages
Solution: Add dataLayer push in product list template
<!-- In catalog/product/list.phtml -->
<script>
dataLayer.push({
'ecommerce': {
'currencyCode': '<?= $block->escapeJs($currencyCode) ?>',
'impressions': [
<?php foreach ($_productCollection as $index => $_product): ?>
{
'id': '<?= $block->escapeJs($_product->getSku()) ?>',
'name': '<?= $block->escapeJs($_product->getName()) ?>',
'price': '<?= $_product->getFinalPrice() ?>',
'list': 'Category Page',
'position': <?= $index + 1 ?>
}<?= ($index < count($_productCollection) - 1) ? ',' : '' ?>
<?php endforeach; ?>
]
},
'event': 'productImpression'
});
</script>
Add to Cart Tracking
Issue: AJAX add to cart not triggering events
Solution: Use Magento's customer-data sections
// Create custom module with mixin
// Vendor/Module/view/frontend/requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Checkout/js/action/get-totals': {
'Vendor_Module/js/get-totals-mixin': true
}
}
}
};
// Vendor/Module/view/frontend/web/js/get-totals-mixin.js
define(['jquery'], function($) {
'use strict';
return function(getTotals) {
return function() {
var result = getTotals.apply(this, arguments);
result.done(function() {
require(['Magento_Customer/js/customer-data'], function(customerData) {
var cart = customerData.get('cart');
console.log('Cart updated, trigger tracking');
if (typeof dataLayer !== 'undefined') {
// Push add to cart event
// Note: Need to track which product was added
}
});
});
return result;
};
};
});
Checkout Step Tracking
Issue: Checkout steps not being tracked
Solution: Implement step tracking in checkout
// Add to checkout page via layout XML or custom module
require([
'Magento_Checkout/js/model/step-navigator',
'Magento_Checkout/js/model/quote'
], function(stepNavigator, quote) {
'use strict';
var currentStep = null;
stepNavigator.steps.subscribe(function(newSteps) {
var activeStep = stepNavigator.getActiveItemIndex();
var stepCode = newSteps[activeStep] ? newSteps[activeStep].code : null;
if (stepCode && stepCode !== currentStep) {
currentStep = stepCode;
var stepNumber = activeStep + 1;
var stepName = stepCode;
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'checkout',
'ecommerce': {
'checkout': {
'actionField': {
'step': stepNumber,
'option': stepName
},
'products': quote.getItems().map(function(item) {
return {
'id': item.sku,
'name': item.name,
'price': item.price,
'quantity': item.qty
};
})
}
}
});
console.log('Checkout step tracked:', stepNumber, stepName);
}
}
});
});
Cookie and Consent-Related Tracking Problems
Magento Cookie Restriction Mode
Magento has built-in cookie restriction mode:
Check if enabled: Stores > Configuration > General > Web > Default Cookie Settings > Cookie Restriction Mode
Impact on tracking:
- Cookies not set until user accepts
- Tracking may be blocked initially
- User must accept cookie notice
Solution for tracking with consent:
// Check cookie restriction status
require(['jquery', 'Magento_Cookie/js/cookie-status'], function($, cookieStatus) {
if (cookieStatus.isAllowed()) {
console.log('Cookies allowed, initialize tracking');
// Initialize GTM or GA
if (typeof dataLayer !== 'undefined') {
dataLayer.push({'event': 'cookiesAccepted'});
}
} else {
console.log('Cookies not allowed yet');
// Listen for cookie acceptance
$(document).on('user:allowed:cookies', function() {
console.log('User accepted cookies');
// Initialize tracking here
});
}
});
GDPR Compliance
For GDPR-compliant tracking:
// Don't track customer PII without consent
// Use hashed or anonymized identifiers
require(['Magento_Customer/js/customer-data'], function(customerData) {
var customer = customerData.get('customer');
customer.subscribe(function(data) {
if (data && data.id) {
// Use customer ID, not email or name
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'user_id': data.id, // Numeric ID, not PII
// Don't include: firstname, lastname, email
});
}
}
});
});
Magento Extension Conflicts
Known Problematic Extensions
Multiple Analytics Extensions:
- Google Analytics by Magento
- Google Tag Manager extensions
- Facebook Pixel extensions
- Third-party analytics modules
Solution: Disable conflicting modules
# List enabled analytics modules
php bin/magento module:status | grep -E "Google|Analytics|Tag|Pixel"
# Disable specific module
php bin/magento module:disable Vendor_GoogleAnalytics
# Re-enable if needed
php bin/magento module:enable Vendor_GoogleAnalytics
# Apply changes
php bin/magento setup:upgrade
php bin/magento cache:flush
Checkout Extensions:
- One Step Checkout
- Amasty Checkout
- Aheadworks One Step Checkout
These change checkout flow and require custom tracking implementation.
Page Builder Extensions:
- Magento Page Builder
- Custom page builders
May alter HTML structure and break selector-based tracking.
Event Tracking Validation Steps
1. Create Custom Tracking Module
Create a custom module for event tracking:
File: app/code/Vendor/Analytics/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_Analytics',
__DIR__
);
File: app/code/Vendor/Analytics/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Analytics" setup_version="1.0.0"/>
</config>
File: app/code/Vendor/Analytics/view/frontend/layout/default.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="before.body.end">
<block class="Magento\Framework\View\Element\Template"
name="analytics.tracking"
template="Vendor_Analytics::tracking.phtml" />
</referenceContainer>
</body>
</page>
File: app/code/Vendor/Analytics/view/frontend/templates/tracking.phtml
<script>
require(['jquery'], function($) {
'use strict';
// Track outbound links
$(document).on('click', 'a[href^="http"]', function(e) {
var href = $(this).attr('href');
var hostname = new URL(href).hostname;
if (hostname !== window.location.hostname) {
console.log('Outbound click:', href);
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'outboundClick',
'outboundUrl': href
});
}
}
});
// Track product quick view
$(document).on('click', '.action.quickview', function() {
var productId = $(this).data('product-id');
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'productQuickView',
'productId': productId
});
}
});
console.log('Custom analytics tracking initialized');
});
</script>
2. Validate Events Fire Correctly
// Add to tracking template or browser console
require(['jquery'], function($) {
if (typeof dataLayer === 'undefined') {
console.error('dataLayer not available');
return;
}
var events = [];
var originalPush = dataLayer.push;
dataLayer.push = function(obj) {
if (obj.event) {
events.push({
time: new Date().toISOString(),
event: obj.event,
data: obj
});
console.log('Event captured:', obj.event, obj);
}
return originalPush.apply(dataLayer, arguments);
};
console.log('Monitoring dataLayer events...');
// Log summary after 30 seconds
setTimeout(function() {
dataLayer.push = originalPush;
console.log('Event monitoring complete. Total events:', events.length);
console.table(events);
}, 30000);
});
Server-Side Caching Considerations
Full Page Cache (FPC)
Magento's built-in FPC can cache tracking code:
Disable for specific blocks:
// In your block class
protected $_isScopePrivate = true;
// Or in layout XML
<block class="..." name="..." cacheable="false" />
Make tracking data dynamic:
<!-- app/code/Vendor/Module/etc/frontend/sections.xml -->
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
<action name="catalog/product/view">
<section name="analytics-data"/>
</action>
</config>
Varnish Configuration
For Magento with Varnish:
Varnish VCL configuration:
# In your Varnish VCL file (default.vcl)
sub vcl_recv {
# Don't cache requests with analytics parameters
if (req.url ~ "(\?|&)(utm_|gclid=|fbclid=)") {
return (pass);
}
# Don't cache checkout or customer account
if (req.url ~ "^/(checkout|customer)") {
return (pass);
}
}
sub vcl_backend_response {
# Don't cache if Set-Cookie header present
if (beresp.http.Set-Cookie) {
set beresp.uncacheable = true;
return (deliver);
}
}
Purge Varnish after changes:
# Via Magento CLI
php bin/magento cache:flush full_page
# Or directly with varnishadm
varnishadm "ban req.url ~ ."
CDN and Proxy Troubleshooting
Cloudflare with Magento
If using Cloudflare:
Bypass cache for tracking parameters:
- Create Page Rule:
*yoursite.com/*utm_* - Cache Level: Bypass
- Create Page Rule:
Disable Rocket Loader for tracking:
<script data-cfasync="false">
// Your GTM or analytics code here
</script>
- Purge cache after tracking changes:
- Cloudflare Dashboard > Caching > Purge Everything
Fastly (Adobe Commerce Cloud)
For Adobe Commerce Cloud with Fastly:
# Purge Fastly cache
php bin/magento cache:clean full_page
# Via Fastly UI or API for specific URLs
Debugging Code Examples
Complete Magento Diagnostic Script
require(['jquery'], function($) {
console.log('=== Magento Analytics Diagnostic ===');
// Magento version
console.log('Magento version:', typeof Magento !== 'undefined' ? 'Magento 2' : 'Unknown/Magento 1');
// RequireJS check
console.log('RequireJS loaded:', typeof require !== 'undefined');
// Tracking setup
var checks = {
'dataLayer exists': typeof dataLayer !== 'undefined',
'dataLayer items': typeof dataLayer !== 'undefined' ? dataLayer.length : 0,
'GTM loaded': !!window.google_tag_manager,
'GA4 (gtag)': typeof gtag !== 'undefined',
'UA (analytics.js)': typeof ga !== 'undefined'
};
console.table(checks);
// Customer data sections
require(['Magento_Customer/js/customer-data'], function(customerData) {
console.log('Customer data sections loaded');
console.log('Section names:', customerData.getExpiredSectionNames());
var cart = customerData.get('cart');
console.log('Cart data:', cart());
var customer = customerData.get('customer');
console.log('Customer logged in:', customer().firstname ? true : false);
});
// Check for ecommerce data in dataLayer
if (typeof dataLayer !== 'undefined') {
var ecommerceEvents = dataLayer.filter(function(item) {
return item.ecommerce;
});
console.log('Ecommerce events in dataLayer:', ecommerceEvents);
}
// Check cache status (visible in page source comments)
var pageSource = document.documentElement.outerHTML;
if (pageSource.includes('FPC=HIT')) {
console.warn('Page served from Full Page Cache');
} else if (pageSource.includes('FPC=MISS')) {
console.log('Page not cached (FPC MISS)');
}
console.log('=== Diagnostic Complete ===');
});
Test Ecommerce Event
// Test adding a product to dataLayer
function testMagentoEcommerceEvent() {
if (typeof dataLayer === 'undefined') {
console.error('❌ dataLayer not available');
return false;
}
dataLayer.push({
'event': 'addToCart',
'ecommerce': {
'currencyCode': 'USD',
'add': {
'products': [{
'id': 'TEST-SKU-123',
'name': 'Test Product',
'price': '99.99',
'quantity': 1,
'category': 'Test Category'
}]
}
}
});
console.log('✓ Test ecommerce event pushed to dataLayer');
console.log('Check GTM Preview or GA4 DebugView for event');
return true;
}
// Run test
testMagentoEcommerceEvent();
When to Contact Support
1. Module Installation Issues
Contact Magento support if:
- Module won't install via Composer
- Setup:upgrade fails
- Module shows as disabled despite enable commands
Provide:
- Magento version
- PHP version
- Composer logs
- Error messages from CLI
2. Caching Problems
Contact if:
- Cache flush doesn't help
- Varnish configuration issues
- Different behavior per cache type
Provide:
- Cache status output
- Varnish VCL file
- Cache configuration from env.php
3. Ecommerce Tracking Issues
Contact if:
- Product data not appearing in dataLayer
- Transaction tracking fails on order success
- Checkout steps not tracking despite code
Provide:
- Example product URL
- Order success page HTML source
- dataLayer content from console
- Network tab screenshots
4. Extension Conflicts
Contact if:
- Multiple extensions conflict
- Can't determine which module causing issue
- Disabling modules breaks site
Provide:
- List of enabled modules
- Browser console errors
- Steps to reproduce
Information to Gather Before Contacting Support
# Run these Magento CLI commands and share output
# Magento version and edition
php bin/magento --version
# List enabled modules
php bin/magento module:status --enabled
# Cache status
php bin/magento cache:status
# Configuration values
php bin/magento config:show google/analytics
php bin/magento config:show web/cookie
# Static content deploy status
ls -la pub/static/frontend/
# Check for JavaScript errors in logs
tail -100 var/log/system.log | grep -i javascript
tail -100 var/log/exception.log
General Fixes
For universal tracking concepts, see the Global Tracking Issues Hub.