Google Tag Manager

Google Tag Manager logo
Deploy and update tracking tags and pixels on websites and apps without editing code.

Google Tag Manager API

Sign in
OAuth 2.0. OAuth 2.0Source

Checked on 2026-10-10 in the developer documentation.

How to use Google Tag Manager

If you’ve decided to implement Google Tag Manager for your B2B marketing efforts, here’s a step-by-step guide to help you get started and make the most of its features.

Setting up Google Tag Manager

Create a Google Tag Manager account: Go to the Google Tag Manager website and sign in with your Google account. After signing up, create a new account and set up a container for your website or app. The container is where all your tags will live.

Install the GTM container code: Once you’ve created your container, GTM will provide you with two snippets of code. Place one snippet in the <head> section and the other in the <body> section of every page on your website. This will enable GTM to manage your tags.

Set up your first tag: After you’ve installed the GTM container, you can begin setting up your tags. To create a new tag, click on “Tags” in the GTM interface, then click “New”. Select the type of tag you want to create (e.g., Google Analytics: GA4 Configuration), and configure it by entering the necessary details (e.g., your tracking ID for Google Analytics).

Read the full guide

Set up triggers: Triggers define when and where your tags should fire. For example, you can set a trigger to fire a tag on all pages, or only on specific pages (like your thank-you page after a conversion). To create a trigger, click on “Triggers” in the GTM interface, then click “New” and set the conditions for the tag to fire.

Use variables: Variables allow you to capture dynamic values, such as the page URL or the value of a form field. To create a new variable, click on “Variables” in the GTM interface, then click “New” and define the variable’s value. You can use these variables in your tags and triggers.

Test your tags: Before publishing your changes, use the “Preview” mode to test your tags and triggers. This ensures that everything is working as expected and allows you to troubleshoot any issues before they go live.

Publish your container: Once you're satisfied with your setup, click on “Submit” to publish your container. This makes your tags live on your website.

Best practices for using Google Tag Manager

Organise your tags, triggers, and variables: Keep your GTM setup organised by using naming conventions and folders. This makes it easier to find and manage tags in the future.

Implement consent management: If you’re subject to privacy regulations like GDPR, make sure that you’re using GTM’s built-in features to manage user consent before firing tags that collect personal data.

Regularly audit your tags: Periodically check your tags to make sure they’re still functioning properly and are relevant to your current marketing efforts.

Leverage debugging tools: GTM has built-in debugging tools that allow you to test and debug your tags before they go live. Use these tools to ensure that everything is working correctly before publishing.

Conclusion

Google Tag Manager is a powerful tool that simplifies tag management and empowers marketers to take control of their tracking setups. By following this guide, you can leverage GTM to improve your B2B marketing efforts. However, it’s important to consider the learning curve and technical aspects of using GTM, especially if you’re working with a large or complex website. With the right setup and attention to detail, GTM can become an indispensable tool for tracking and optimising your marketing campaigns.

How to automate Google Tag Manager

API and webhooks

The Tag Manager API v2 is official. It can read containers, and create tags, triggers, variables and workspaces. It can also publish versions and manage user permissions. Use a test account first, because changes through the API are not protected by confirmations.

One idea: a script that copies a standard set of tags from a template container into every new client or site container.

Native integrations

GTM has tag templates for the common analytics and advertising platforms, and it works with Google Analytics, Google Ads and others. Custom HTML covers the rest. One idea: use a single container to fire HubSpot form events and ad conversions from the same data layer event.

MCP server

There is no official Tag Manager MCP server yet. If you want an assistant to help, use the API through your own scripts and keep a human review step before publishing.