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:

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.

<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


WordPress Page Loads Blank on Edit

When your WordPress page loads blank when you try to edit it, it often points to a conflict or resou...

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...

Ajax search functionality in WordPress

Implementing AJAX search functionality in WordPress enhances user experience by enabling live search...

How to Fix Empty href Tags When Displaying Custom Tag Cloud as a List in WordPress

Fixing empty href tags in a custom tag cloud displayed as a list in WordPress usually involves ensur...

Recent Posts