Implementing third-party tags in Google Tag Manager (GTM) is an essential part of setting up web analytics, marketing, and tracking on your website. These tags allow you to send data to third-party services like Google Analytics, Facebook Ads, or other marketing platforms. GTM simplifies the process of adding and managing these tags without needing to modify the website’s code, making it accessible for non-technical users.
In this guide, we’ll explore how to implement third-party tags using GTM, covering the step-by-step process, best practices, and common use cases.
What are Third-Party Tags?
Third-party tags are snippets of code that you add to your website to send data to external platforms. These tags can be used for various purposes, such as:
- Tracking user behavior (e.g., Google Analytics, Mixpanel)
- Retargeting visitors (e.g., Facebook Pixel, AdRoll)
- Conversion tracking (e.g., Google Ads Conversion Tag, LinkedIn Insight Tag)
- Marketing automation (e.g., HubSpot, ActiveCampaign)
Each third-party service usually provides its own unique code snippet or JavaScript file, which is used to collect or send data.
Why Use Google Tag Manager for Third-Party Tags?
Using Google Tag Manager for third-party tags offers several benefits:
- Centralized Tag Management: You can manage all your third-party tags from a single interface rather than adding them directly to the website’s source code.
- Tag Firing Control: You can control when and where tags fire by setting up specific triggers.
- Version Control: You can easily create and publish new versions of your GTM container, allowing for smooth rollbacks if necessary.
- Security and Load Optimization: GTM’s built-in controls help ensure tags are loaded efficiently, preventing performance bottlenecks and security issues.
Steps to Implement Third-Party Tags in Google Tag Manager
1. Set Up a Google Tag Manager Account
If you haven’t already, you’ll need to create a Google Tag Manager account:
- Go to tagmanager.google.com and sign in with your Google account.
- Create a new account and container, selecting your website’s domain and platform (e.g., Web).
- Follow the on-screen instructions to install the GTM container code snippet on your website. This will allow GTM to manage your tags on the site.
2. Understand the Third-Party Tag Requirements
Before adding any third-party tag to GTM, you need to:
- Get the Tag Code or ID: Most third-party services, such as Google Analytics or Facebook Pixel, provide a unique piece of code or an ID that you’ll need to integrate.
- Read Documentation: Go through the platform’s documentation to understand the data that needs to be collected and any additional setup requirements, like custom events or triggers.
3. Create a New Tag in Google Tag Manager
To add a third-party tag to your website using GTM:
- Go to the GTM Dashboard and click Tags in the left-hand menu.
- Click the New button to create a new tag.
- Name the tag something descriptive, like “Google Analytics – Pageview” or “Facebook Pixel – Page Load.”
4. Choose the Tag Type
In the Tag Configuration section, you’ll choose the tag type that matches the third-party service. GTM comes with many built-in tag templates for popular services, but if the service you’re using isn’t listed, you can use the Custom HTML or Custom Image options.
Common Third-Party Tags with Built-In Templates
- Google Analytics: GTM supports Universal Analytics and Google Analytics 4 natively.
- Facebook Pixel: GTM has a template for the Facebook Pixel.
- Google Ads: GTM includes templates for conversion tracking, remarketing, and dynamic remarketing for Google Ads.
- LinkedIn Insight Tag: Use this template for LinkedIn ad tracking.
Custom Tags
If the third-party tag you need isn’t supported by a built-in template:
- Select Custom HTML Tag if the third-party service provides JavaScript that needs to be executed on the page. Paste the script code directly into the provided field.
- Select Custom Image Tag if you need to fire a tracking pixel or an image-based tag. Enter the URL of the tracking pixel.
5. Configure Tag Settings
For tags with built-in templates, you’ll need to configure the specific settings that apply to your tag. For example:
- Google Analytics (GA4): You’ll need to enter your Measurement ID.
- Google Ads Conversion Tracking: You’ll need your Conversion ID and Conversion Label.
- Facebook Pixel: You’ll need to enter your Pixel ID and choose the type of event you want to track (e.g., Page View, Purchase, Lead).
For Custom HTML or Custom Image tags, the script or image URL you received from the third-party service should be pasted directly into the configuration field.
6. Set Up Triggers
Triggers define when your third-party tag will fire. For most tags, the trigger will depend on the action or event you’re tracking, such as a page load or button click.
- Click “Triggering” in the tag editor to define the conditions under which the tag should fire.
- You can choose from default triggers like:
- All Pages: Fires the tag on every page of the site. Common for analytics or retargeting tags.
- Page View: Fires the tag when a specific page or set of pages is viewed.
- Click: Fires the tag when a user clicks a specific element on the page (useful for tracking button clicks or form submissions).
- Custom Events: You can set up custom events to track user actions (e.g., form submissions, video plays).
For example, for a Facebook Pixel page view tag, you would set the trigger to fire on All Pages. For a Google Ads conversion tracking tag, you might set the trigger to fire only on the Thank You page after a form submission.
7. Test Your Tags
After configuring your tag and trigger, it’s essential to test your setup before publishing it to your live site.
- Click Preview in the GTM dashboard. This will open Preview Mode, allowing you to interact with your site in real-time and see which tags are firing.
- Navigate to your website in Preview Mode and check if the tags are firing correctly. You should see which tags fired (or didn’t) in the Tag Assistant window.
- For more complex tags like Google Analytics or Facebook Pixel, you can use additional browser tools like the Facebook Pixel Helper or Google Analytics Debugger to confirm data is being sent correctly.
8. Publish the Tag
Once you’ve tested and confirmed that the third-party tag works as expected:
- Click Submit in GTM to publish the container with your new tag.
- Add a version name and description to the container update. This is useful for tracking changes over time and troubleshooting if something breaks in the future.
9. Verify Data Collection in Third-Party Platforms
After publishing your tag:
- Log in to the respective third-party platform (e.g., Facebook Ads Manager, Google Analytics, etc.).
- Check whether the data from your tags is being collected correctly. For example, in Google Analytics, you can check real-time reports to see if the page views or events are being tracked.
Common Use Cases for Third-Party Tags in GTM
Here are a few common third-party tags you might want to implement using GTM:
- Google Analytics (GA4) Setup:
- Add a GA4 configuration tag for site-wide tracking.
- Set up custom event tracking (e.g., button clicks, form submissions) using event tags and triggers.
- Facebook Pixel Tracking:
- Implement a Facebook Pixel tag to track page views and custom events (e.g., Add to Cart, Purchase).
- Use Facebook’s standard event options or create custom events for more granular tracking.
- Google Ads Conversion Tracking:
- Set up a conversion tag to track purchases, sign-ups, or other conversion events.
- Combine it with remarketing tags to build custom audiences for ad retargeting.
- LinkedIn Insight Tag:
- Add a LinkedIn Insight Tag for conversion tracking and audience retargeting.
- Configure triggers to fire the tag on relevant pages (e.g., thank you pages, product pages).
- HubSpot Tracking:
- Add HubSpot’s tracking code to collect form submissions and user behavior for marketing automation.
Best Practices for Third-Party Tags in GTM
- Use Clear Naming Conventions: Use descriptive names for your tags, triggers, and variables to make managing your GTM container easier, especially when working with multiple third-party tags.
- Test Before Publishing: Always use GTM’s Preview Mode to test your tags before publishing them.
- Use Appropriate Triggers: Make sure that tags only fire when necessary. For example, conversion tags should only fire on specific conversion actions (e.g., form submissions or purchase completions).
- Regularly Review Tags: Periodically review your tags to ensure that they’re firing as expected and that no unnecessary tags are slowing down your site.