Webflow sync, pageviews & more.
NEW

What is the best way to transfer Google Tag Manager (GTM) codes and pixel from an existing WordPress site to a new Webflow (WF) site with 301 redirects and a cleaner URL structure? Should I create a new container in GTM for the WF site and build all tags from scratch, or can I copy the master GTM tags and paste them in the new WF site, continuing as normal?

TL;DR
  • Reuse your existing GTM container and embed its code in Webflow's custom code sections.
  • Audit and update GTM triggers for new URL structures, implement 301 redirects in Webflow’s hosting settings, and test all tags and redirects for proper functionality.

To migrate Google Tag Manager (GTM) and tracking (e.g., pixels) from WordPress to Webflow while implementing 301 redirects and a cleaner URL structure, you don’t need a brand-new GTM container.

1. Use the Same GTM Container

  • Reuse your existing GTM container to maintain all current tags, triggers, and variables.
  • GTM is site-agnostic; it doesn't depend on your CMS and works by detecting site-based triggers like page views, clicks, or URLs.

2. Update the GTM Code in Webflow

  • In your Webflow project, go to Project Settings > Custom Code.
  • Paste your GTM container snippet:
  • Add the head code inside the “Head Code” section.
  • Add the body code (noscript tag) inside the “Before tag” section.
  • Publish the site for changes to apply.

3. Retest All GTM Tags and Triggers

  • Since Webflow’s structure may change URL paths, element classes, or IDs, retesting is critical.
  • Use Preview mode in GTM and Google Tag Assistant, checking for:
  • Pageviews firing correctly on new URLs
  • Click triggers correctly mapped to the new site's DOM elements
  • Pixels (like Facebook or LinkedIn) firing as expected

4. Adjust Triggers for New URL Structure (If Needed)

  • If your Webflow site uses a different URL pattern (e.g., dropped /blog/ or simplified paths), update any URL-based triggers in GTM.
  • Use RegEx matching or updated Page Path/URL Equals conditions to match the cleaned-up structure.

5. Implement 301 Redirects Inside Webflow

  • In your Webflow site, go to Project Settings > Hosting > 301 Redirects.
  • Enter your old WordPress URLs and redirect them to their new Webflow equivalents using the “Old Path” → “New Path” format.
  • Ensure that important legacy URLs are preserved or properly redirected to maintain SEO value.

6. Verify Redirects and Tag Firing

  • Use tools like Screaming Frog or Ahrefs to crawl your old site and confirm all redirects are working.
  • Use the Facebook Pixel Helper, Google Tag Assistant, and Chrome DevTools to validate tag execution.

Summary

Keep using your existing GTM container, and embed the same code in Webflow’s custom code sections. Then audit and adjust triggers for new URLs or element structures. Confirm that all tracking tags and redirects perform correctly on the new site.

Rate this answer

Other Webflow Questions