Installing Google Tag Manager (GTM) on your website is a crucial step for managing your tracking codes efficiently. This process allows you to add and update tags (like Google Analytics, Facebook Pixels, etc.) without modifying the actual code of your website. Here’s a detailed guide on how to install Google Tag Manager on your website.
1. Create a Google Tag Manager Account
Before you can install GTM, you need to create an account and container. If you’ve already done this, you can skip this step.
Step 1: Sign Up for Google Tag Manager
- Go to the Google Tag Manager website.
- Click on the “Sign Up for Free” button.
- Sign in with your Google account if prompted.
Step 2: Create a New Account
- After signing in, you’ll see a screen to create a new account.
- Enter your account name (usually your business name).
- Choose your country from the dropdown menu.
Step 3: Set Up a Container
- Enter a name for your container (typically the name of your website).
- Choose where to use the container (select “Web” for websites).
- Click “Create.”
Step 4: Accept the Terms of Service
- Review the Google Tag Manager Terms of Service.
- Click “Yes” to accept the terms and proceed.
2. Install the GTM Code Snippet
Once you create your GTM account and container, you’ll receive two snippets of code that you need to install on your website.
Step 1: Copy the GTM Code
After creating your container, you will see two code snippets displayed on the screen:
- First Snippet (Head): This code should be placed in the
<head>
section of your website. - Second Snippet (Body): This code should be placed immediately after the opening
<body>
tag.
Example Code Snippet:
3. Add the GTM Code to Your Website
For HTML Websites:
- Open your website’s HTML files in a text editor or IDE.
- Locate the
<head>
tag in your HTML document. - Paste the first snippet of code you copied just before the closing
</head>
tag. - Locate the opening
<body>
tag. - Paste the second snippet immediately after the opening
<body>
tag.
For Content Management Systems (CMS):
- WordPress:
- You can either add the code manually by editing your theme’s header file (
header.php
) or use a plugin such as “Insert Headers and Footers” to easily input the GTM code snippets.
- You can either add the code manually by editing your theme’s header file (
- Shopify:
- Go to
Online Store
>Themes
>Actions
>Edit code
. - Open the
theme.liquid
file and paste the GTM code in the appropriate sections as mentioned above.
- Go to
- Wix:
- In Wix, go to
Settings
>Tracking & Analytics
>New Tool
>Google Tag Manager
. - Enter your GTM ID and follow the prompts to add GTM to your site.
- In Wix, go to
4. Verifying the Installation
After adding the GTM code to your website, it’s essential to verify that it has been installed correctly.
Step 1: Use Google Tag Assistant
- Install the Google Tag Assistant Chrome extension.
- Once installed, open your website.
- Click on the Tag Assistant icon and select “Enable.”
- Refresh your webpage. The Tag Assistant will show which tags are present and whether they are firing correctly.
Step 2: Use GTM Preview Mode
- Go back to your Google Tag Manager workspace.
- Click on the “Preview” button in the upper right corner.
- Enter your website’s URL and click “Connect.”
- This will open a new tab showing your website with a GTM debugger at the bottom.
- As you navigate through your site, the debugger will display which tags are firing. Ensure that the GTM container tag is successfully triggered.
5. Publishing Your GTM Container
Once you have verified that your tags are working correctly, you can start adding additional tags and triggers.
Step 1: Create a New Tag
- In the GTM workspace, click on “Tags” in the left sidebar.
- Click on “New” to create a new tag.
- Name your tag and select the type of tag (e.g., Google Analytics).
- Configure the tag settings and add triggers as needed.
Step 2: Submit Changes
- After creating your tags and triggers, click on the “Submit” button in the upper right corner.
- Provide a version name and description to document the changes.
- Click “Publish” to make the tags live on your site.
6. Best Practices for GTM Installation
- Document Changes: Maintain a log of changes made in GTM for future reference.
- Organize Tags: Use a clear naming convention for tags, triggers, and variables for easier management.
- Regular Testing: Periodically test tags to ensure they function as expected.
Conclusion
Installing Google Tag Manager on your website is a straightforward process that greatly simplifies managing your marketing tags and tracking codes. By following the steps outlined above, you can efficiently set up GTM, verify its installation, and begin using it to enhance your website’s tracking capabilities. With GTM, you’ll have the flexibility to add, update, and manage tags without the need for constant code changes, allowing for more agility in your marketing efforts.