Implementing third-party tags in Google Tag Manager (GTM) is essential for businesses that rely on various marketing, analytics, and tracking services. GTM offers a centralized, flexible solution to manage all your tags without directly modifying the website code. This tutorial will provide a comprehensive guide on setting up and using third-party tags in GTM, ensuring your implementation is efficient and effective.
Table of Contents
Toggle1. Set Up Google Tag Manager
Creating a Container
- Log in to GTM:
- Visit Google Tag Manager and log in with your Google account.
- Create a Container:
- If you don’t have a container, click Create Account. Provide your account name (usually your company name), country, and container name (usually your website name).
- Choose the container type (Web, iOS, Android, or AMP).
- Click Create and agree to the terms of service.
Installing GTM on Your Website
- Get the GTM Code Snippet:
- After creating the container, GTM will provide a code snippet.
- Copy the code snippet.
- Add the GTM Code to Your Website:
- Paste the first part of the snippet immediately after the opening
<head>
tag on every page of your website. - Paste the second part of the snippet immediately after the opening
<body>
tag on every page of your website.
- Paste the first part of the snippet immediately after the opening
2. Obtain the Third-Party Tag Code
- Identify the Third-Party Service:
- Determine which third-party service (e.g., Facebook Pixel, LinkedIn Insight Tag, Twitter Universal Website Tag) you need to implement.
- Get the Tag Code:
- Visit the third-party service’s website and follow their instructions to generate the tag code. This often involves setting up an account and configuring your tracking settings.
3. Create a New Tag in GTM
Creating the Tag
- Go to the tags Section:
- In your GTM container, navigate to the Tags section in the left-hand menu.
- Create a New Tag:
- Click on New to create a new tag.
- Name your tag descriptively, such as “Facebook Pixel” or “LinkedIn Insight Tag”.
4. Configure the Tag
Using Built-In Templates
- Choose Tag Type:
- Click on Tag Configuration.
- GTM provides built-in templates for several popular third-party tags, such as Google Analytics, Facebook Pixel, and LinkedIn Insight Tag. Select the relevant tag type from the list.
- Enter Tag Details:
- For example, if using the Facebook Pixel, you’ll need to enter your Facebook Pixel ID.
- Fill in any additional required fields based on the tag type. This could include specific event names or custom parameters.
Using Custom HTML Tag
- Select Custom HTML Tag:
- If GTM doesn’t have a built-in template for your third-party tag, select Custom HTML Tag.
- Paste the Tag Code:
- Copy the tag code you obtained from the third-party service and paste it into the HTML text area in GTM.
5. Add Triggers
Choosing or Creating Triggers
- Click on Triggering:
- Click on Triggering to add a trigger to your tag.
- Choose an Existing Trigger:
- Select an existing trigger from the list. Common triggers include All Pages, Page View, Click, or Form Submission.
- Create a New Trigger:
- If necessary, create a new trigger by clicking on the + button.
- Choose the trigger type (e.g., Page View, Click).
- Configure the trigger conditions based on when you want the tag to fire (e.g., all pages, specific page URL, button clicks).
- Name and save the trigger.
6. Test the Tag Configuration
Using GTM Preview Mode
- Enable Preview Mode:
- Click on Preview in GTM to enable preview mode. This will open the GTM Debug console.
- Check the Tag on Your Website:
- Open your website in a new tab with the GTM debug console active.
- Navigate through your website to verify that the third-party tag fires correctly according to the triggers you set.
Using Tag Debugging Tools
- Google Tag Assistant:
- Install the Google Tag Assistant Chrome extension.
- Use this tool to verify that the third-party tag is firing as expected.
- Browser Developer Tools:
- Open your browser’s developer tools (usually by pressing
F12
or right-clicking on the page and selecting Inspect). - Go to the Network tab to check for requests made by the third-party tag.
- Open your browser’s developer tools (usually by pressing
7. Publish Your Container
Submitting and Publishing Changes
- Submit Your Changes:
- Once you’ve confirmed that the tag is working correctly, return to GTM.
- Click on Submit.
- Publish Your Container:
- Add a version name and description summarizing the changes.
- Click Publish to make your changes live.
Example Implementations
Example 1: Implementing a Facebook Pixel
- Create the Tag:
- Go to Tags > New.
- Click Tag Configuration and select Facebook Pixel.
- Enter Pixel ID:
- Enter your Facebook Pixel ID.
- Add Trigger:
- Click on Triggering and select All Pages or create a custom trigger.
- Save and Publish:
- Save the tag, submit, and publish the container.
Example 2: Implementing a Custom HTML Tag for a Third-Party Service
- Create the Tag:
- Go to Tags > New.
- Click Tag Configuration and select Custom HTML Tag.
- Paste the Tag Code:
- Copy the third-party tag code and paste it into the HTML text area.
- Add Trigger:
- Click on Triggering and select an appropriate trigger (e.g., All Pages).
- Save and Publish:
- Save the tag, submit, and publish the container.
Advanced Tips
Using Variables
- Create Custom Variables:
- Use GTM variables to dynamically insert data into your tags. For example, create a variable to capture the page URL or user ID.
- Configure Variable Settings:
- Go to the Variables section in GTM.
- Click on New to create a new variable.
- Choose the variable type (e.g., URL, Data Layer Variable).
- Configure the variable settings as needed.
- Use Variables in Tags:
- In your tag configuration, use the variables by referencing them within the tag code or settings.
Error Handling
- Ensure that your custom HTML tags include error handling to prevent issues if the third-party service is unavailable.
- Implement Error Handling in Custom HTML Tags.
Consent Management
- Integrate with Consent Management Platforms (CMPs):
- Ensure compliance with privacy regulations by integrating your tags with a consent management tool like Google Consent Mode or a third-party CMP.
- Use triggers and variables to conditionally fire tags based on user consent.
2. Configure Tags Based on User Consent
By following these detailed steps, you can efficiently implement and manage third-party tags using Google Tag Manager. GTM provides a centralized and flexible way to handle various marketing and analytics tags, ensuring your website remains easy to maintain and update. Regular testing, updating, and documentation will help maintain the effectiveness and reliability of your third-party tag implementations, ultimately contributing to better data accuracy and more effective marketing efforts.