Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Add Google Tag Manager to WordPress

This guide shows you how to connect Google Tag Manager to your WordPress site.

WordPress2 min read15 steps13 screenshots

What is Google Tag Manager?

Google Tag Manager is a free tool from Google. It helps you add tracking codes to your site in one place. A tracking code is a small piece of code that counts visitors or watches clicks. Each code is called a tag.

Think of it as a box with a single plug. You plug the box into your site once. After that you add or remove tags inside the box, without touching your site again.

Before you start

  1. Go to the Google Tag Manager website and sign in with a Google account.
    Google Tag account
  2. Click Create Account.
    Account Setup
  3. Type an account name and your website address. Choose Web as the target.
  4. Accept the terms.
  5. Copy your container ID. It starts with GTM-, for example GTM-XXXXXX.

Add it with a plugin

A plugin is an add-on for WordPress. This is the safest way for beginners.

  1. Log in to your WordPress dashboard.
  2. Go to Plugins and click Add New.
  3. Search for Google Tag Manager. Pick a well-reviewed plugin that was updated recently.
  4. Click Install Now and then Activate.
  5. Open the plugin's settings. Look under Settings or in the new menu it adds.
  6. Paste your container ID in the box.
    Container Setup section
    Data Processing Terms
  7. Click Save Changes.
    install google tag manager

Check that it works

  1. Go back to Tag Manager and click Preview.
    codes
  2. Type your site address and click Connect.
    header
    tag manager preview
  3. Your site opens in a new tab. If the container loads, the setup is correct.
    connect tag assistance

Add it by hand (advanced)

Tag Manager gives you two pieces of code. One goes as high as possible inside the <head> of every page. The other goes right after the opening <body> tag. Many themes have a place for header and footer code. Back up your site before editing theme files. A small typo can break the site.

new tag
tag configuration
Tip: Do not add the same container twice. It will count every visit double.

Quick recap

  • Tag Manager holds your tracking codes in one place.
    tag type
  • Create a container and copy the GTM- ID.
    tag configuration preview
  • Paste the ID into a Tag Manager plugin and save.
  • Use Preview to test.