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 paste the GTM code into Webflow's custom code areas (head and before body).
  • Update tags/triggers for any changes in selectors or structure, set up 301 redirects in Webflow, preserve pixel tracking, and test thoroughly to ensure accurate event firing.

To migrate Google Tag Manager (GTM) from a WordPress site to a new Webflow site with 301 redirects and an improved URL structure, you can reuse your existing GTM container—a full rebuild is usually not necessary.

1. Reuse Your Existing GTM Container

  • You do not need to create a new container. Your GTM setup (tags, triggers, variables) can shift to the new site as long as the logic still matches the user flow.
  • Because GTM is platform-agnostic, your existing tags and events will still function as long as the new Webflow site maintains relevant element IDs, classes, and page structures.
  • Only rebuild tags if your new Webflow design fundamentally changes element selectors, page structure, or tracking goals.

2. Add GTM to Webflow

  • In Webflow, go to Project Settings > Custom Code.
  • Paste your GTM container code in two places:
  • Head code: Paste the <script> code snippet provided by GTM.
  • Body code: Paste the <noscript> iframe version into the Before tag section.
  • These two placements mimic what your WordPress theme likely had in its template files.

3. Update Tags/Triggers if Necessary

  • Review your existing tags in GTM:
  • Tags based on CSS selectors or page URLs may need updates to match the new Webflow structure.
  • If you're using trigger conditions like Page URL or Click Classes, validate that these selectors are consistent in Webflow.
  • For some actions (e.g., form submissions), Webflow uses custom events like form-submit-success, so you may need to adjust triggers accordingly.

4. Set Up 301 Redirects in Webflow

  • In Webflow, go to Project Settings > Hosting > 301 Redirects.
  • Add 301 rules from WordPress URLs to their new Webflow equivalents.
  • These redirects preserve SEO value and ensure that GTM events tied to traffic sources continue to attribute properly.

5. Preserve Pixel Tracking

  • If you have Facebook Pixel, Google Ads, or LinkedIn Insight Tag in GTM, they will continue working as long as:
  • The GTM container is active and placed properly on the site.
  • Any dynamic event tracking (like product view or add to cart) uses matching selectors or is updated per Webflow’s structure.

6. Test Thoroughly

  • Use Google Tag Assistant or Preview mode in GTM to test that tags are firing correctly.
  • Use GA4 DebugView to check for real-time event tracking.
  • Set up correct URL-based triggers if your new site uses cleaner slugs or folder structures.

Summary

Reusing your current GTM container is the best approach. Add the existing GTM code snippets to Webflow’s custom code areas, update any CSS selectors or triggers as needed, and maintain functionality without rebuilding from scratch. Check all tags and test after implementing to account for any changes in the Webflow layout or URL structure.

Rate this answer

Other Webflow Questions