Google Tag Manager is Breaking My Oxygen-Built Website (WordPress)

Fix: Google Tag Manager Breaking Oxygen-Built WordPress Website

If Google Tag Manager (GTM) is causing issues on your Oxygen-built website, here are common reasons and how to fix them.

Possible Causes & Fixes

1. Oxygen’s JavaScript Conflicts

Oxygen Builder loads scripts differently, which can conflict with GTM.

Fix: Load GTM asynchronously to prevent blocking Oxygen scripts.

Add this snippet to “Code Snippets” or functions.php:

1
2
3
4
5
6
function add_gtm_async() {
    ?>
    <script async src="https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXX"></script>
    <?php
}
add_action('wp_head', 'add_gtm_async', 5);

Replace GTM-XXXXXX with your GTM ID.

2. GTM Container Placement Issues

If GTM was added via Oxygen’s settings, it might not execute properly.

Fix: Insert GTM manually using Oxygen’s “Code Block” feature.

  • Go to Oxygen > Templates.
  • Edit the Main Template.
  • Add a Code Block.
  • Paste your GTM <script> in the Head section.
  • Paste the <noscript> part in the Body section.

3. Page Loading or Layout Issues

GTM may interfere with Oxygen’s CSS or JavaScript.

Fix: Defer GTM’s execution so Oxygen loads first.

1
2
3
4
5
6
7
8
9
10
<script>
  window.addEventListener('load', function() {
      setTimeout(function() {
          var gtmScript = document.createElement('script');
          gtmScript.async = true;
          gtmScript.src = 'https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXX';
          document.head.appendChild(gtmScript);
      }, 1500); // Delay by 1.5 seconds
  });
</script>

4. GTM Conflicting with Oxygen’s Optimizations

Oxygen’s caching or script minification may block GTM.

Fix: Exclude GTM from Oxygen’s optimizations.

  • Go to Oxygen > Settings > Bloat Eliminator.
  • Disable “Remove jQuery Migrate” (if enabled).
  • Exclude googletagmanager.com from minification or lazy loading.

5. Errors in Google Tag Manager Preview Mode

If GTM isn’t working correctly, check your browser console for:

  • CORS Policy Errors: GTM requests blocked due to security settings.
  • GTM Firing Too Soon: Events triggering before Oxygen loads.

Fix: Use GTM’s built-in “DOM Ready” trigger instead of “Page View.”

Final Checks

  • ✔ Clear Oxygen Cache (Oxygen > Settings > CSS Cache > Regenerate).
  • ✔ Use GTM Debug Mode to check for conflicts.
  • ✔ Disable other plugins (like security or cache plugins) to troubleshoot.

If your Oxygen site is still breaking, what specific issues are you facing—layout glitches, missing elements, or something else?

Related Posts


Auto create an user account after WooCommerce checkout without Plugin

To automatically create a user account after WooCommerce checkout, you can use the woocommerce_thank...

How to Retrieve and Expose Gutenberg & Theme-Generated CSS in WordPress

If you want to extract the CSS generated by Gutenberg and your WordPress theme, you can do so using ...

WP Pagination Not Working for Custom Query: Troubleshooting Tips

Ever struggled with WordPress pagination code? Fret not! We’ve got your back. In this post, we...

How to Retain Local Storage When Changing WooCommerce Payment Method?

When users switch payment methods on the WooCommerce checkout page, local storage data may reset, ca...