Google Tag Manager (GTM) is a powerful tool that allows you to manage various tracking codes and scripts on your website from a single interface. Whether you’re looking to integrate analytics, conversion tracking, or other marketing tags, GTM simplifies the process. In this article, we’ll guide you through two methods to install Google Tag Manager in your WordPress website: using a plugin or manually adding the code.
Method 1: Installing Google Tag Manager via Plugin
Step 1: Install and Activate a GTM Plugin
- Log in to your WordPress dashboard.
- Navigate to “Plugins” and click on “Add New.”
- Search for “Google Tag Manager” in the plugin search bar.
- Choose a suitable plugin (e.g., “DuracellTomi’s Google Tag Manager (GTM4WP), Site Kit by Google or “Insert Headers and Footers“).
- Click “Install Now” next to the chosen plugin and then activate it.
Step 2: Configure the GTM Plugin
- Locate the plugin settings page, which is typically found under “Settings” or “Tools.”
- Access your Google Tag Manager account and create a new container.
- Copy the GTM container ID provided by Google (e.g., GTM-XXXXXX).
- Return to your WordPress dashboard and enter the container ID into the plugin settings.
- Save the changes, and Google Tag Manager will be installed on your WordPress site.
Method 2: Installing Google Tag Manager Manually
Step 1: Access the WordPress Theme Files
- Log in to your WordPress dashboard.
- Navigate to “Appearance” and click on “Theme Editor.”
Step 2: Edit the Theme Header File
- On the Theme Editor page, locate the active theme on the right-hand side.
- Click on the “header.php” file listed under the active theme’s files.
- Note: It’s always a good practice to create a backup of the file before making any changes.
Step 3: Add the Google Tag Manager Code
- Access your Google Tag Manager account and create a new container.
- Copy the GTM container code snippet provided by Google.
- In the Theme Editor, find the
<head>
section within the “header.php” file. - Paste the GTM container code snippet immediately before the closing
</head>
tag.
Step 4: Verify Installation
- Log in to your WordPress dashboard.
- Install and activate the “Google Tag Assistant” extension for your browser (e.g., Chrome).
- Visit your website in a new browser tab.
- Click on the Google Tag Assistant extension icon in your browser’s toolbar.
- The extension will run a diagnostic check and confirm if Google Tag Manager is successfully installed.