Wordpress

How to Add Google Tag Manager to WordPress

Instructions for Classic Themes

  1. In your WordPress dashboard, navigate to Appearance → Editor.

  2. Open the header.php file of your active theme.

  3. Locate the <head> tag and paste the Google Tag Manager head snippet inside it.

  4. Next, locate the opening <body> tag.

  5. Paste the second Google Tag Manager snippet immediately after the <body> tag.

Instructions for Block Themes

Option 1 (cleanest): Use Google’s Site Kit

  1. Install Site Kit by Google.

  2. In WP admin: Site Kit → Settings → Connect More Services → Tag Manager

  3. Select your GTM Container ID, finish setup, and Site Kit will place the code automatically. Google Help+2Site Kit by Google+2

Option 2 (most common plugin): GTM4WP

  1. Install “GTM4WP – A Google Tag Manager plugin for WordPress”.

  2. Enter your GTM container ID in the plugin settings.

  3. It injects both the <head> and <body> snippets for you. WordPress.org+1

Option 3 (manual, best if you want no plugin): add via hooks

Use a child theme (or a Code Snippets plugin) and add:

// 1) Head snippet
add_action('wp_head', function () { ?>
<!-- Google Tag Manager -->
<!-- paste the <script> snippet here -->
<!-- End Google Tag Manager -->
<?php });
// 2) Body snippet (right after <body>)
add_action(‘wp_body_open’, function () { ?>
<!– Google Tag Manager (noscript) –>
<!– paste the <noscript> snippet here –>
<!– End Google Tag Manager (noscript) –>
<?php });

Below are a few YouTubes shows how to use Tag Manager to track clicks and button clicks.

Leave a Reply

Your email address will not be published. Required fields are marked *