Manage your WordPress site

How to add Google Tag Manager to WordPress

Tag Manager comes as two small codes: one for the page header and one right after the body opens. Paste both once and you can add every other tag from Tag Manager.

  • Time: About 5 minutes
  • You need: A WordPress administrator login and a Tag Manager container
  • Updated:

With Tag Manager installed, new tracking (Analytics, Google Ads conversions, the Meta pixel) is added inside Tag Manager instead of in your site’s code. If you use Site Kit, it can place the container for you: in Site Kit > Settings > Connect more services, set up Tag Manager and let Site Kit place the code.

Before you start

  • A Tag Manager account with a web container for your site. Its ID starts with GTM-.
  • The free WPCode plugin (search for it under Plugins > Add Plugin).
  • If your Google Analytics tag is already pasted on the site, plan to remove it once Analytics runs inside Tag Manager, so visits aren’t counted twice.
  1. Step 1: Open your container’s install codes

    In Tag Manager, on the Workspace tab, click your container ID (GTM- followed by letters) at the top. The Install Google Tag Manager window shows two codes.

    Tag Manager install window with the container ID and both code boxes circled
    Illustration: click the GTM- ID to see both codes.
  2. Step 2: Open Header & Footer in WordPress

    In your WordPress dashboard, go to Code Snippets > Header & Footer.

  3. Step 3: Paste the first code into Header

    Copy the first code (it starts with <!-- Google Tag Manager -->) and paste it into the Header box.

    WPCode Header and Footer screen with the Tag Manager codes in the Header and Body boxes and Save Changes circled
    WordPress 7.1 with WPCode: code 1 in Header, code 2 in Body, then Save Changes.
  4. Step 4: Paste the second code into Body

    Copy the second code (the one with noscript) and paste it into the Body box, just below Header.

  5. Step 5: Save and test

    Click Save Changes. Back in Tag Manager, click Preview, enter your website address and click Connect. If Tag Assistant says it’s connected, the container is working.

Quick answers

Can I skip the Body code?

The Header code does almost all the work. The Body code only matters for visitors with JavaScript turned off. Add both: it takes ten seconds.

I published a tag but nothing changed.

Tags only go live after you click Submit and Publish in Tag Manager. Preview mode only shows changes to you.

Official help pages

Checked against these pages on November 3, 2026.