Marketers: Install Google Tag Manager on Your WordPress Site in 4 Minutes


50% of the top million websites use Google Tag Manager, the incredibly powerful analytics/marketing tool that quickly deploys tagging across your website. Want to do Facebook remarketing? Subscribing to HubSpot, Pardot or another marketing automation service? Need to add an AdWords conversion tag?

So many actions marketers take require additional tracking code to be placed on website code and Google Tag Manager will handle that for us. Best of all, you don’t have to be an analytics nerd to implement this! Tag Manager empowers marketers to own and make changes without development or technical help. I’m not a coder at all, and I’ve launched GTM on a few dozen WordPress websites.

In the simplest configuration, Google Tag Manager fires and controls the Google Analytics tag on your website. See our post “What is Google Tag Manager? (And How Does It Work With Google Analytics?)” below for more gushing.

Here’s What You’ll Need:

  • Knowledge Of Self: Critical for all marketing projects but for today, ask yourself: Does my website have tons of traffic and lots of QA checks and dev process to do anything? If so, go talk to IT about this just to make sure it’s cool. If you are working on small-to-medium sized business or non-profit, proceed!
  • WordPress Admin Access. This needs to be a WordPress site you control and have access to make admin-level changes.
  • Google Account. Ideally the one you use for Google Analytics.
  • Google Chrome Browser. You can download Chrome here.
  • Egg Timer. Mine looks like a Penguin because LunaMetrics is in Pittsburgh.


1. Set Egg Timer for 4 minutes

Easy, right?

2. Sign Up for Google Tag Manager

Navigate to the Tag Manager page and to sign up for free. 

google tag manager sign up page

Create a new GTM account. Account name best practice: Use your company name (e.g. Alice’s Wonderland Resorts LLC).

google tag manager account name screenshot

Now name your container and choose what you want to track. Since we’re talking about WordPress websites here, select Web. Container name best practice: Use the domain name of your website (e.g.

create google tag manager container

3. Get Dat Code

Yes, I told you this wouldn’t be technical. It’s not! We just need to do a few copy / pastes. Once you click create, you’ll be presented with the following popup that contains the code that needs to be added to your site. This code snippet will have your Container ID, which is super important! Mine below is just an example. Don’t use it.

4. WordPress Editor

In WordPress, navigate to Appearance, then Editor. If you don’t see this option, then you do not have Admin access to your site.


Look on the right-hand side and you’ll see the files the make your WordPress template work. Look for Header.php and edit. This files controls all page templates in WordPress.

Paste the top portion of GTM code right after the opening <head> element (see screenshot). Use your browser search to locate the <head> if needed.


Paste the second portion of GTM code right after the opening <body> element.


Don’t monkey around with other stuff! Seriously.

When you’re done, click Update File.

5. Import a Recipe (If you Want to do GA Stuff) Or Add a Tag for a Non-Google Service

Head over to and grab our basic recipe pack for GTM to do some Google Analytics tracking. This GTM pack will allow you to easily add ready-to-go tags to your new GTM container. If you have Google Analytics installed already, the recipe instructions will tell you how to add your tracking number to GTM.


Note: you don’t have to set up Google Analytics through Tag Manager, but it’s recommended. You can install Tag Manager and leave your existing Analytics in place. Learn about how Google Tag Manager and Google Analytics can work together.

Super Important Note: Google Analytics should only load on your page once. If you’re using a different WordPress plugin to load Google Analytics, then do not also load Google Analytics through Google Tag Manager.

Maybe you just need to install a Facebook remarketing snippet without a developer, use Tag Manager! But if you would like to migrate your Google Analytics tracking to Tag Manager, see our blog post that covers some other points about migrating your on-page Google Analytics to Google Tag Manager.

If you need to set up tracking for external service because you want to do some advanced marketing tracking or measure conversions from social or paid ad spends, it’s easy! Google Tag Manager comes pre-loaded with tons of external tags (view list) or you can use a special tag called a Custom HTML Tag to paste in other tags.

Here are GTM instructions for integrating popular marketing tags:

Remember to test your tags before publishing them. Google Tag Manager has built-in previewing and debugging. We also cover a few Chrome extensions for debugging that will come in handy!

6. Verify Your Install

Tag Assistant is a nifty freebie will look for the GTM container in your site source code and let you know that everything works. Add Google Tag Assistant to Chrome from the Chrome Store.


Now, re-load your website and open Tag Assistant. You should see a happy little face with your container ID:


Ding! My timer just rang. Did you make it? Remember, you don’t have to migrate Google Analytics right away if you just need to get one advertising tag on your site via GTM. You can do that step next (Spoiler: it takes longer than 4 minutes) and we’d love to help. Have you done a quick & dirty GTM launch like this in the past?

Michael Bartholow is a Senior Account Manager. He has a special knack for B2B Lead Generation and e-Commerce Marketing. Michael holds an Integrative Arts degree from Penn State University and uses the same SEO & PPC skills he once employed to promote award-winning independent films to help businesses across a variety of verticals find audiences. He has Google certifications in Analytics & AdWords.

  • Marcos

    Great post. Quick question, if you modify your header.php don’t all your tags will be lost if you update your theme? In other words, if you update your theme, you will have to install GTM again. Ok it’s only 4 minutes but still.

    • Marcos – You can avoid that problem of switching themes, by using a plugin that accepts the snippet. For example, we have a free plugin on the WP repository called Header Footer Code Manager. You can simply paste your snippet in there, and that would resolve any potential issue of losing your snippet if you switch themes.

      • Mario Zelada

        I’m using a child theme to go around it. But somehow my analytics tag is not deploying on all pages. Can you help?

        • PatrickTT

          Hi Mario! =)
          Ruf mich an wenn du bei sowas Hilfe brauchst! =)
          (Hab dich durch Zufall hier gefunden!)

  • DuracellTomi

    (shameless self promotion)

    …or you can use my GTM WP plugin if you do not want to edit your theme files and also get some fancy dataLayer content without coding 😉

  • I am very new to Google Tag Manager, this is the easiest tutorial I have found ever, so far without the confusion. I got one major confusion cleared now, Wheather to add GA code first and then add GTM tags. Thanks for sharing this time saver information with us.

    • Hi Nikhil!

      GTM goes first, then you’ll fire the GA code from within GTM. Good luck! Thanks for the kind words.

  • Sunil Williams

    This is kinda dicey for non-developers.

    Editing theme code directly via the wordpress editor is risky. If a mistake is made then the site can be unusable.
    It’s easy enough to recover from this kind of breakage… but only if the site operator has a reasonably good knowledge of WordPress.

    • This is true! I’ll add a warning to post.

    • Alain Nijholt

      Never edit it before you’ve saved a copy ;-P

  • Izabela Worsztynowicz

    hi! the tutorial is really easy to follow which is great – i am looking for simple way to install GTM without many conflicting options. However, I have on my WP GA code already in place and totally empty GTM but still, when I use the method you describe I end up having GA code implemented 3 times on each site according to How can that be? Would appreciate any thoughts on this 🙂

    • Hi Izabela,

      Thanks much. You will have to remove existing on-page GA code or turn off any GA plugins before firing GA through GTM. If you care to post your site, I’d be happy to take a quick look.

      • Izabela Worsztynowicz

        sure thing- its this page: I am checking it with the tool: where it shows 3 implementations of GA code its strange for me because my container in GMT is empty, and before was fine –
        the tool showed 1 implementation. Thank you for looking at it!

        • Izabela,

          Things are in good shape. I checked the code of the sitr and only see 1 GA installation. Here’s a screencap from Tag Assistant too:

          Another way to verify that things are ok would be to check Analytics and look for a doubling or tripling of sessions, suggesting that you had 2 or 3 duplicate GA tracking tags each firing pageview hits. gachecker is erroring for whatever reason. I often use it and haven’t seen it do that before!

          • Izabela Worsztynowicz


            Thanks a lot for advice! 🙂

  • Takumi Suzumori

    BEST tag manager installation post
    thank you!!

  • Mario Zelada

    Some how my Pageviw all pages tag is not deploying on all pages.

    • Mario Zelada

      please help!

    • Mario Zelada

      I’m using a child theme, but with header.php file Help!

  • Ted Bigham

    I have seen other posts that recommend using ‘Insert Headers and Footers’ plugin for WordPress. Is there any advantage or disadvantage of using header.php vs using the plugin?

  • Peter Kirwan

    Possible typo? “freebies on” Did you mean .com?

  • Before editing any .php file I would suggest that you take a backup of it and then edit the file. In case any mistake takes place one can always reinstate the original file. I am very comfortable in editing php files and I shouldn’t be having any issues. You have explained things so easily.

  • Daniel Lira

    What if the wordpress theme doesn’t provide a header.php file?

  • Rwth

    Thank you for such a clearly written and easy to follow post. I followed your step-by-step instructions and managed to successfully add GTM in the space of a few minutes.

  • Jalil Jahanzaib Khan

    I implement GTM guide from this article on

  • Patrick

    This helped a lot.

    Thank you, Michael.

  • Hi Michael, great post. I just tried following it and I’m getting the following errors:
    * An error occured while the tag was fired: net::ERR_ABORTED

    * Error while sending request: net::ERR_ABORTED

    Just wondering if you, or anyone here, has come across this. Thanks!

Contact Us.

Follow Us



We'll get back to you
in ONE business day.
Our Locations
THE FOUNDRY [map] LunaMetrics

24 S. 18th Street
Suite 100

Pittsburgh, PA 15203


4115 N. Ravenswood
Suite 101
Chicago, IL 60613


2100 Manchester Rd.
Building C, Suite 1750
Wheaton, IL 60187