How to add Google Tag Manager (GTM) to a site

Updated:

Categories: , ,

Author:

Prepare Your GTM Code

You should receive two GTM code snippets from Google:

  • One for the <head> section
  • One for immediately after the opening <body> tag

Example GTM Code:

Note:

  • If you use a child theme, make edits there to prevent overwriting during theme updates.

Paste this code as high in the <head> of the page as possible:

The <head> tag would be found in the header.php file.


Paste this code immediately after the opening <body> tag:

The <body> tag can also be found in the header.php file.

Sometimes, if the theme is heavily customized, the opening tag could be inside specific templates like:

  • page.php (for pages)
  • single.php (for posts)
  • archive.php (for archive pages)

Verify the connection is working

  • Push you changes
  • Open your website in a new tab
  • Use the Tag Assistant to verify the GTM tag is firing correctly