Setting up GTM

Google Tag Manager helps you manage analytics and advertising tags through a single container. Once installed, you can connect Google Analytics 4, Google Ads, and Meta Pixel, track form submissions, clicks, purchases, and other user actions without constantly editing your website template.

Setting up GTM
106
clients over six years of work
120%
average traffic growth in the first year
184%
organic revenue growth per year
85%
average landing page conversion

What is Google Tag Manager and why do I need it?

Properly setting up GTM starts with understanding what data your business truly needs. Simply setting up a container and adding a few tags without an event map will quickly result in duplicates, redundant events, and metrics in your reports that are difficult to use for analyzing advertising or visitor behavior.

Google Tag Manager, or GTM, is Google's tag management system. It allows you to add analytics and advertising scripts to your website, set up their execution conditions, transmit user action parameters, and test the settings before publishing the container.

Searches often include terms like "GTM Manager" and "GTM It", although the official name of the service is Google Tag Manager. It's often used in conjunction with Google Analytics 4, as GTM conveniently manages data submission, while GA4 receives this data and generates reports.

In practice, GTM is needed where analytics needs to be configured for multiple data sources. A single container allows you to connect Google Analytics, Google Ads tags, Meta Pixel, custom JavaScript, and other systems without manually adding each new script to the page code.

How does GTM work?

Once installed, the GTM container loads along with the page and checks the specified conditions. If the user performs an action that matches the trigger, the appropriate tag is fired and transmits data to the connected service.

For example, a visitor clicks a form submit button. GTM records the action, checks the trigger conditions, and fires a GA4 event tag. An event appears in Google Analytics, which can then be used for lead analysis and, if necessary, marked as a key event.

The data transfer scheme can be represented as follows:

Website → GTM container → trigger → tag → GA4 or advertising system → report

For a more complex setup, a Data Layer is added between the site and GTM. The developer passes the values needed for analytics to this layer: purchase amount, product ID, form type, transaction_id, authorization status, and other parameters.

Google Tag Manager Basics

Three basic elements are used within the container: tags, triggers, and variables. These elements work together, so errors in one element often result in an event not being dispatched or triggering multiple times.

Before creating a large number of settings, it's best to agree on clear names. A tag's name should clearly indicate where it sends data and what action it tracks. This approach simplifies container auditing several months after the initial setup.

Tags

The tag contains the action GTM should perform after the selected trigger is triggered. Most often, it sends data to Google Analytics, Google Ads, Meta, or another service, but you can also run your own scripts through custom HTML.

The production container can use a Google tag for GA4, an event tag, an advertising tag, a remarketing tag, or custom JavaScript. Parameters and trigger conditions are defined for each tag, so a single container can serve multiple analytics systems simultaneously.

Before publishing, you should check that the tag is firing only where intended. If the same tag fires twice for the same action, your statistics will be inflated, and the number of conversions will no longer reflect actual leads or purchases.

Common Mistakes When Setting Up GTM and Google Analytics

Most analytics issues stem not from the complexity of the GTM interface, but from duplicates, inaccurate conditions, and a lack of post-implementation testing. Errors can go undetected for months if the team relies solely on the numbers in the reports.

Before launching advertising, it's advisable to conduct a basic container audit and compare events with actual website activity. If analytics show twice as many requests as your CRM, your advertising campaign optimization will be based on incorrect data.

GTM is installed on the site twice

Duplication occurs when a single container is added via a plugin, theme code, and system integration simultaneously. The browser loads multiple instances of the same GTM, and associated tags may fire repeatedly.

You can check the issue through the source code, Tag Assistant, and network requests. Once identified, you should stick to a consistent installation method that won't disappear after a CMS or theme update.

Before removing unnecessary code, make sure it actually duplicates the same container. A complex project may use different containers, so use the GTM-... ID as a guide.

Google Analytics is installed directly and simultaneously via GTM

If the same GA4 stream receives PageViews from both a direct Google tag and GTM, data may be duplicated. A similar issue arises with events if the old implementation remains in the code after being moved to a container.

Before migrating, find the Google Analytics tracking code in your CMS templates, plugins, and settings. Then compare its Measurement ID with the ID used in GTM.

The old installation is removed only after the new scheme has been verified. This procedure reduces the risk of both integrations being disabled simultaneously, resulting in analytics ceasing to collect data.

GTM ID and GA4 Measurement ID are mixed up

The GTM ID begins with GTM-, and the GA4 dimension ID begins with G-. These values refer to different services and are used in different configuration areas.

Confusion often arises when a website owner requests a Google Analytics code and sends the developer only one identifier without explanation. For implementation, it's better to include the service name and the full value format.

You can also record the ID separately in the project's technical documentation. This reduces verification time when, after several months, you need to determine which resource and container are associated with the site.

GTM changes saved but not published

Saving a tag doesn't mean the change is live for regular visitors. Until the new container version is published, the setting is available in the workspace and Preview, but it doesn't become part of the live configuration.

Before publishing, you should check all changed tags and then reopen the site without Preview. This monitoring helps quickly identify version-related or cache-related issues.

It's helpful to include a brief reason for the change in the publication description. The container history then shows when a specific setting was introduced and who added it.

The event fires multiple times

A duplicate event may occur due to a trigger that is too broad, multiple identical tags, or a duplicate Custom Event being sent via the Data Layer. The cause should be identified in the event sequence in Preview.

For a form, check whether the tag fires simultaneously on a click and on a successful submission. In this case, a single request could create two records, even though the user performed a single target action.

After fixing the issue, test several consecutive submissions and page refreshes. A proper setup should produce a predictable number of events for each scenario.

Tags not verified via Preview

Publishing without Preview leaves too many unknowns. Even a simple click trigger might fail due to a different class, a dynamic link, or JavaScript issues on the page.

Before launching, it's worth performing the action manually and checking the Tags Fired, Variables, and resulting event in the receiving system. This check takes less time than subsequently searching for the cause of incorrect statistics.

Ecommerce, forms, and advertising conversions require particular attention. Errors in these events directly impact reports, audiences, and budget decisions.

How to connect Google Analytics 4 via GTM?

After installing the container, you can connect GA4 via a Google tag. To do this, you'll need the measurement ID from your Google Analytics web stream, which begins with G-.

This option is convenient if you plan to configure events, Google Ads, Meta Pixel, or e-commerce later. All major changes can be made in one container, tested in Preview, and published only after testing.

01

Where can I get Google Analytics code?

To find web stream data, open the GA4 resource settings, go to Data Streams, and select the desired site. The stream card displays the Measurement ID (G-XXXXXXXXXX), which is used when connecting Google Tag via GTM.

Users searching for a Google Analytics code or a Google Analytics code often have this identifier in mind. However, the full Google Analytics code and the Measurement ID are different pieces of information, so you need to determine your chosen connection method before installation.

If you need direct Google Analytics code, you can open the installation instructions in the stream settings and switch to the manual option. This displays the full gtag.js fragment, which can be embedded in your website's HTML.

02

Where can I get the Google Analytics counter code?

The phrase "where to get the Google Analytics counter code" has persisted since previous versions of Analytics, so it's still used by website owners and specialists. In GA4, instead of the familiar term "counter", people often refer to Google tags and Measurement ID.

When installed directly, the Google Analytics counter code is a JavaScript fragment that loads the gtag.js library and contains the ID of the desired stream. When installed via GTM, simply obtain the Measurement ID and add it to the corresponding Google Tag setting.

Therefore, the queries "Google Analytics counter code" and "Google Analytics tracking code" may describe different parts of the same task. Before implementation, determine whether you need a full HTML script or analytics integration via a GTM container.

03

How to get Google Analytics code for manual installation?

To obtain the Google Analytics code, open the GA4 web stream and follow the manual installation instructions. The system displays a JavaScript fragment containing the library connection and the measurement ID of the selected resource.

This option is suitable for a site where analytics is connected directly and there is no need to manage a large number of marketing tags. Google Analytics code can be obtained without a separate GTM container if the direct installation method is chosen.

The phrase "install Google Analytics" typically refers to the same operation: get a Google tag, add it to the template, and check the data flow. After installation, you should ensure that the correct resource, data stream, and domain are being used.

04

Where to paste the Google Analytics code?

The answer depends on the chosen connection method. If a direct Google tag is used, the script is placed within the <head> of all site pages where statistics need to be collected.

If GTM is used, the location of the Google Analytics code is determined within the container. In this case, the GTM code is included in the template, and the Google tag is created through the tag manager interface and receives the Measurement ID of the desired stream.

Therefore, queries such as "Google Analytics where to insert code", "Google Analytics where to place code", and "Where to insert Google Analytics code" cannot be considered separately from the chosen installation method. Simultaneously connecting the same stream in two ways requires special checking for duplicates.

Direct installation of Google Analytics

With direct installation, the Google Analytics code is added to all relevant pages immediately after the beginning of the <head> section. This method is suitable for basic statistics collection if the site doesn't require a complex system of tags and events.

Installing a Google Analytics counter via direct code requires checking templates. In a CMS, one general template typically covers most pages, but landing pages, individual modules, or external forms may have their own structure.

After installation, open your website and check for pageviews in GA4. If data isn't appearing, check the Measurement ID, source code, Consent Mode restrictions, ad blockers, and JavaScript errors.

Installing Google Analytics via GTM

When connecting via GTM, a Google tag is created in the container, a Measurement ID of the form G-... is specified, and a trigger is assigned that runs on all required pages. The configuration is then tested in Preview and a new version of the container is published.

Installing a Google Analytics counter via GTM is convenient because subsequent events can be created within the same structure. You don't have to add new code directly to the website template each time if the desired action is already available via GTM or Data Layer.

After publishing, it's a good idea to check GA4 DebugView and regular reports. Preview confirms the tag's execution in GTM, but a separate check in Analytics shows whether the data reached the intended resource.

05

Google Analytics in head or via GTM – which method to choose?

The choice depends on the number of integrations and the planned depth of analytics. For a simple site with basic pageview tracking, a direct Google tag may be sufficient, especially if the settings are rarely changed.

GTM is more convenient when multiple advertising systems, user events, e-commerce, or regular analytics updates are required. However, the container itself also requires careful maintenance, clear names, and mandatory testing before publication.

WayWhen it suitsAdvantagesWhat to consider
Google tag in <head>Need basic GA4 without complex integrationsSimple connection diagram and minimum settingsNew events may require additional coding work.
Google Analytics via GTMWe need events, advertising, e-commerce, and several services.All tags are managed through a single container.You need to monitor triggers, duplicates, and container versions.

If the old analytics setup is already working on the site, there's no need to change the connection method just for the sake of the migration. First, it's worth checking the current data and understanding what the new setup will actually solve.

06

What is Google Analytics asynchronous code?

Asynchronous Google Analytics code loads an external script without the need to completely stop page processing until it finishes loading. Modern Google Tag and GTM implementations use an approach that prevents analytics code from consistently blocking the entire page.

However, the mere presence of asynchronous loading doesn't mean that all marketing scripts are speed-safe. A large number of heavy third-party tags can impact performance, especially if they are unnecessarily executed on every page.

When auditing, it's important to look not only at the connection format but also at the number of tags, their launch conditions, and the actual tasks. Sometimes, several old ad scripts continue to load for years, even though the campaigns for which they were added have already been disabled.

What we actually did

Dental clinic · Kyiv and Chernihiv

+44% clicks from search

A domain with no history and a site on a website builder. We built the semantic core for both cities, reworked the landing pages and built the link profile from zero. In four months: 34.8k clicks, impressions 1.32 → 1.76M, DR 0 → 41.

E-commerce · international

+96% clicks in two months

A catalog of digital 3D models. We clustered the semantics, rebuilt the hub pages and fixed duplicates and indexing errors. Google users 247 → 532, CTR 2.4% → 4%.

Medical center · Ukraine

+68.75% visibility in the first month

Narrow visibility and a small semantic core at the start. Semantics, landing page structure, metadata and internal linking, then gradual link building.

Answers to your questions

What is GTM and how is it different from Google Analytics?

Google Tag Manager manages tags, their firing conditions, and the transfer of data from the page. Google Analytics 4 receives analytics events and generates reports on users, traffic sources, and website activity.

Typically, these services work together: GTM determines when to send an event, and GA4 receives it and stores it for later analysis. With a simple setup, Google Analytics can work without GTM via a direct Google tag.

Where can I get Google Analytics 4 code?

In the GA4 resource settings, open the web data stream for the desired website. It displays a Measurement ID of the form G-XXXXXXXXXX, and the full code for manual connection is available in the installation instructions.

If analytics is installed via GTM, Measurement ID is typically used. If the direct method is chosen, the full Google tag fragment is required, which is added to the HTML of all required pages.

Where to insert Google Analytics code?

When installed directly, the Google tag is placed within the <head> tag on the site's pages. If Analytics is connected via Google Tag Manager, the GTM container is installed in the template, and GA4 configuration is performed through its interface.

Therefore, the answer to the Google Analytics question of where to insert the code depends on the implementation scheme. Don't use both options for the same stream without testing, as this could result in duplicate views and events.

Do I need to install Google Analytics in both the head and GTM?

For the same GA4 stream, one consistent connection method is usually sufficient. If one Google tag works directly in the <head> and the other sends the same data through GTM, statistics may be duplicated.

Before migrating, you should test the old installation and only shut it down after a successful GTM test. This procedure preserves data collection continuity and reduces the risk of double uploads.

Where is the Google Tag Manager code installed?

GTM's main JavaScript fragment is placed as high as possible within the <head> tag. The second fragment, with noscript, is placed immediately after the opening <body> tag.

The container must be present on all pages requiring analytics. After implementation, several templates should be tested using Tag Assistant, as individual sections of the site may use a different structure.

Is it possible to set up GTM without a programmer?

Basic installation, page views, simple clicks, and some standard events can be configured without a developer. This requires access to the website or native CMS environment and an understanding of tags, triggers, and variables.

A developer is most often needed for Data Layer, e-commerce, custom forms, and complex JavaScript scenarios. In such cases, it's more reliable to transmit a confirmed event from the site than to try to determine it solely from external page elements.

How to check if Google Analytics is working through GTM?

First, open Preview and ensure the Google tag and the required events appear in Tags Fired. Then, check the events in GA4 DebugView to ensure they're being sent to the correct resource.

After publishing, it's worth reviewing the regular reports and performing test actions without Preview mode. Checking at multiple levels helps isolate a GTM issue from an error in the GA4 resource itself.

Is it possible to install Facebook Pixel via GTM?

Meta Pixel can be connected via Google Tag Manager and triggers the desired events. Before implementation, check whether the same pixel is already installed via the CMS, theme code, or another integration.

GTM can transmit PageView, Lead, AddToCart, Purchase, and other events. Each of these events should be verified in Meta tools and matched with the actual user action on the site.

Setting up GTM involves several sequential steps: installing the container, connecting Google Analytics 4, defining the required events, testing triggers, and publishing only after testing. For a simple website, some of the work can be done independently, but complex forms, e-commerce, and the Data Layer require more detailed technical setup.

If GA4 already contains duplicates, missed requests, or an unclear event structure, it's best to start with an audit of the current container and installed codes. After checking, you can create an event map, remove unnecessary integrations, and configure GTM to ensure the data matches actual user actions.

We reply within one business day. No newsletters, no “just a reminder” calls.

Gennadii, Lead SEO Specialist, Seo-Gen
He will look at the site himself instead of passing it to a manager.
Who will answer: Gennadii
Lead SEO Specialist, Seo-Gen

More on: Setting up GTM

How do I create a Google Tag Manager account and container?

The process begins with creating a GTM account and a separate container for your website. At this stage, you need to select the correct container type and use a descriptive name, especially if your company has multiple domains or separate projects.

A single primary web container is typically created for a single website. Creating multiple containers unnecessarily complicates maintenance, as the developer and marketer must verify the settings in each container.

Creating a GTM account

After logging into Google Tag Manager, you need to create an account, enter your company name, select your country, add a container name, and select the "Web" platform. For a regular website, a web container is used. After accepting the terms, the service displays an installation code.

It's best to associate the container name with a specific domain. This format helps quickly navigate the account if a single account manages a corporate website, an online store, a landing page, and a test project.

After creation, there's no need to add dozens of tags at once. First, install the container on the site, check the load using Tag Assistant, then enable basic analytics, and only then move on to events.

Where can I find the GTM container ID?

The container ID is displayed in the Google Tag Manager interface and has the format GTM-XXXXXXX. This identifier is specific to the container and is used in the code installed on the website pages.

It is often confused with the Google Analytics 4 Measurement ID. The Measurement ID has the format G-XXXXXXXXXX and is specific to the GA4 data stream, so the G-... value cannot be inserted in place of the GTM-... container ID.

When testing the setup, it's helpful to immediately record both identifiers in the project's technical documentation. Then, during subsequent audits, you can quickly determine which container is being loaded on the site and which Google Analytics property is receiving the events.

How to install Google Tag Manager on a website?

After creating the container, GTM displays two code snippets. These need to be placed in different parts of the HTML to ensure the container loads correctly and works on all pages that require data collection.

The installation method depends on the CMS and project architecture. If built-in integration is available, it's best to use system settings or a separate module that persists across theme updates. Manually editing template files is only recommended when there's no other secure method.

Where to insert GTM code?

The first GTM fragment is JavaScript and is placed within the <head> . The second contains noscript and is placed after the opening <body> . Both fragments belong to the same container and use the same ID, such as GTM-....

The code must be installed on all pages where analytics are required. If the container is present only on part of the site, the user may navigate between pages, and data for certain stages of the journey will be lost or collected incompletely.

After installation, you should check the source code and Tag Assistant. This check helps identify situations where the developer has inserted a fragment into only one template, while other page types are generated by a separate layout without GTM.

GTM code in <head>

The main JavaScript fragment is placed as high as possible within the <head> section. The sooner the browser loads the container, the sooner GTM can process the tag triggers that should fire when the page loads.

The fragment must be located within the actual HTML template used on all relevant pages. If the site runs on a CMS, it is recommended not to insert it directly into the parent theme file if the system supports a separate field, child theme, or secure module.

Requests like "google analytics head" often lead to confusion between GTM and direct Google tag installation. While both are indeed placed in the <head> tag, when using GTM, direct Google Analytics code usually doesn't need to be duplicated in the template.

GTM code after <body>

The second fragment contains a noscript block and is placed immediately after the opening <body> tag. It belongs to the same GTM container and is used as an additional mechanism for limited scenarios when JavaScript is unavailable.

This block shouldn't be inserted randomly into a page using the visual editor. It should be placed in the template near the beginning of the <body> section. Otherwise, the installation structure will differ from the recommended one and complicate subsequent technical audits.

After changing the template, you need to clear the server and CMS caches, if they are used. Then, open several different page types and ensure that both fragments contain the correct container ID.

How to install GTM via CMS?

In WordPress, a container can be enabled via a specialized plugin, Code Snippets (if implemented appropriately), or child theme files. The same principle applies to WooCommerce, but when setting up e-commerce, a Data Layer with product and order data is often additionally required.

Shopify, Wix, OpenCart, Horoshop, and other platforms have their own methods for connecting external scripts. If the CMS provides a separate system field for GTM, it's usually wiser to use it rather than manually editing files that could be overwritten after an update.

On a custom website, the developer places both fragments in a common template. After installation, the home page, categories, cards, forms, and other templates need to be tested to ensure the container is present everywhere web analytics needs to be implemented.

How to check if GTM is installed correctly?

Preview Mode and Google Tag Assistant are used for testing. After connecting the site, you can see the container loading, the sequence of events, the list of Tags Fired and Tags Not Fired, and the variable values for each step.

If GTM isn't detected, first check the container ID, code placement, and cache. Then, ensure the script isn't blocked by Consent Mode settings, a browser extension, the site's security policy, or a template error.

It's also worth checking for duplicates. A single container is sometimes simultaneously enabled via a plugin, theme code, and external integration, causing events to be sent multiple times for a single action.

How to set up Google Analytics events via GTM?

After the basic GA4 connection is established, you can move on to user actions. For each event, you need to define the exact triggering time, parameters, event name, and verification method.

An event should reflect a clear action. The fewer random and duplicate events reported to GA4, the easier it is to work with reports, build audiences, and evaluate advertising results.

Setting up a button click

For clicks, GTM can use Click Text, Click Classes, Click ID, and Click URL. The choice of variable depends on the page markup and which attribute remains stable after text or design changes.

For example, it's best to track the submit button using a unique ID or stable class, if available. The button text may change after an A/B test or localization, which could cause the trigger to stop firing.

Before publishing, open Preview, perform the required click, and view the variable values. After that, you can configure the trigger conditions based on real data, rather than an assumption about the HTML structure.

Setting up a click on a phone number

Phone number links typically use the tel: format. In GTM, you can create a link click trigger and constrain it with the Click URL starts with tel: condition so that the event is sent only when the phone number is clicked.

The event name in GA4 should be clear and consistent across the entire project. If the site has multiple phone numbers, the number or button location can be passed as a separate parameter, avoiding the creation of dozens of nearly identical events.

This click indicates an intent to contact the company, but does not confirm a call. When analyzing it, it should be treated as a user action on the website, and actual phone call data should be obtained from a separate system, if one is connected.

Setting up form submission

Forms require careful testing because modern websites often submit data via AJAX and don't trigger the standard HTML form submit event. The same trigger may work correctly on an older form but fail to respond to a form created by a newer JavaScript component.

A reliable method depends on the website's implementation. You can use a standard Form Submission, a thank-you page, or a custom event via the Data Layer that is sent only after the form has been successfully processed.

After setup, you need to test successful submission, required field error, and resubmission. This test ensures that a simple button click, without any actual data transfer, isn't counted as a request.

Standard Form Submission

The Form Submission trigger is suitable for classic HTML forms, where the browser actually triggers a standard submit event. Before using it, you should test it in Preview on a specific site.

On forms using AJAX, React, or custom handlers, the standard trigger may fail to fire or fire before successful submission is confirmed. In this case, analytics will begin counting submission attempts as real leads.

If the standard option works reliably, it's better to limit the conditions to the desired form or page. A general trigger for all forms without validation could mix up inquiries, subscriptions, searches, and other interface elements.

Thank you page

If, after successfully completing the form, the user is redirected to a separate URL like /thank-you/, visiting that page can be used as the event condition. This method is easier to test and doesn't depend on the structure of the button itself.

You need to ensure that the thank you page can't be opened accidentally from the menu or search results. It's also worth checking that users aren't refreshing the page multiple times, creating repeated events without a new request.

When implemented correctly, this option is suitable for many service websites. For complex funnels or multiple forms with different lead types, it's more convenient to pass individual values through the Data Layer.

Event via Data Layer

The Data Layer allows the developer to push an event only after a successful result on the website. For example, after the server's response, dataLayer.push can be executed with the event name and specific form parameters.

This method is less dependent on button text, CSS classes, and layout changes. A Custom Event trigger is created in GTM that responds to the desired event name and fires the corresponding GA4 tag.

For complex forms, this approach is usually more reliable than visual conventions. In the specifications, the developer must pre-define the event name, the sending time, and the set of parameters so that analytics receives a stable data structure.

Adjusting scroll depth

GTM can track Scroll Depth and send events when a specified page depth is reached. This data helps assess how far users scroll through long articles, landing pages, and e-commerce pages.

Don't automatically consider every scroll a key event. Viewing 50 or 90 percent of a page can be a useful behavioral metric, but it doesn't in itself confirm an inquiry, call, or purchase.

For long-form content, a few clear levels are sufficient. Sending events too frequently creates unnecessary noise and complicates analysis, especially if the scroll depth isn't related to a specific user decision.

How to make an event a key event in GA4?

Once an event is received in GA4, it can be marked as a key event if the action is truly associated with an important outcome. For a service website, such events often include a successful request or other confirmed request.

Not every event needs to be turned into a key event. Clicks, scrolls, or card views help analyze behavior, but equating every action with a business outcome distorts the evaluation of channels and advertising campaigns.

After changing the status, you should check your reports and advertising integrations. If key events are imported into Google Ads, you should separately monitor the accounting model and ensure that the same conversion is not being duplicated from multiple sources.

What is Data Layer in GTM?

The Data Layer is used to pass structured information from the website to Google Tag Manager. It allows for the transmission of values that are difficult or unreliable to obtain from visible HTML.

The site sends an object with the required parameters, GTM reads it through variables and uses the values inside the tags. This approach is especially useful for online stores, complex forms, and projects where analytics must work independently of minor layout changes.

What data is transferred through the Data Layer?

The data layer can be used to pass successful form submission, form name, internal ID, product type, price, currency, quantity, transaction_id, and other parameters needed for analytics.

There's no need to transfer all your website data without a specific goal. It's best to define the structure in advance, linking each parameter to the report, advertising audience, or test for which it will actually be used.

Personal data requirements must also be considered. You cannot blindly submit phone numbers, email addresses, or other values to analytics systems that may violate the platform's rules or the project's internal requirements.

Data Layer for an online store

For ecommerce, GA4 uses the view_item, add_to_cart, begin_checkout, purchase, and other events. The event also passes parameters such as product, price, currency, and transaction ID.

The unique transaction_id is especially important for purchases. It helps correctly handle repeated openings of the confirmation page and maintain the connection between the purchase event and a specific order.

Before launching e-commerce, it's important to test several products, varying quantities, discounts, and test purchases. Data Layer structure errors often only manifest themselves in specific scenarios, so simply checking the product card isn't enough.

Setting up Facebook events via GTM

Facebook event setup via gtm is used to send actions to the Meta advertising system. Interfaces now use the name Meta Pixel, although the search term "Facebook Pixel" still appears in instructions and searches.

GTM allows you to manage basic pixel loading and individual events. Before publishing, ensure that PageView and target actions are not simultaneously sent from the site code, CMS integration, and container.

How to install Meta Pixel via GTM?

First, obtain the Pixel ID in the Meta ad account, then create a suitable tag in GTM and assign a trigger condition. The basic PageView should typically trigger on the desired pages after the pixel loads.

The implementation method depends on the tag template used and the project's requirements. After configuration, open Preview and the Meta Event Tester to ensure the browser is actually sending data to the intended Pixel ID.

If the pixel was previously installed via the CMS or manually, the old integration should be verified before publishing GTM. Two identical PageViews on the same pageview will distort statistics and audiences.

How to set up Meta Events via GTM?

Lead, Purchase, AddToCart, and other actions that correspond to actual user behavior can be used for advertising. The trigger can be linked to the same user action already tracked in GA4.

Meta and Google Analytics parameters are configured separately. A single user action can trigger multiple tags, but each platform should be checked using its own diagnostic tools.

For purchases via the Data Layer, you can pass the price and currency if these values are available and correctly formed. Avoid setting fixed amounts for all orders when the actual price varies.

How do I check events and tags before publishing?

Any change to GTM should be tested before publishing. The test should cover the trigger itself, the execution of the required tag, and the actual receipt of the event by the system to which the data is sent.

A single Preview only shows part of the picture. If a tag is marked as Fired, you should additionally verify that the event has appeared in GA4 DebugView, your advertising platform, or another endpoint service.

Preview and Tag Assistant

In Preview mode, enter the website address, connect to the Tag Assistant session, and perform the required actions. The interface displays the sequence of events and a list of tags that have fired or remain in the Tags Not Fired category.

For each step, you can view Variables and Data Layer values. This helps you understand why a condition failed, which URL GTM retrieved, and what value was in Click Text, Click Classes, or a custom variable.

After testing, you should check multiple scenarios, not just a single successful action. For example, a request trigger should fire after a successful form submission, but not after a validation error or a simple button click.

Checking events in GA4 DebugView

GA4 DebugView displays events received by the resource during testing. Here you can check the event name, parameters, and user action sequence.

If a tag fires in GTM but the event is missing from DebugView, you need to check the Measurement ID, tag parameters, user consent, browser restrictions, and resource settings.

After a successful test, it's worth checking the standard reports after the data appears. DebugView is used for diagnostics, and the production reports help ensure that the new analytics setting has been correctly integrated into the overall statistics collection.

Publishing a container

After review, the changes are submitted via Submit and a new version of the container is created. It's a good idea to include the tags, events, or fixes added in the version name and description.

Version history simplifies GTM support. If a new setting causes a problem, a specialist can compare the changes with the previous configuration and quickly determine the cause.

Publishing several unrelated changes as one large version is undesirable. Small, clear versions are easier to test, document, and roll back if necessary.

When is it best to entrust GTM setup to a specialist?

Basic container setup and a simple event can be handled independently if the site has a clear structure and the specialist is familiar with GTM principles. Complexity quickly increases when multiple domains, AJAX forms, e-commerce, advertising systems, and a custom data layer are added.

Professional setup usually begins with an audit of existing tags and an event map. This process helps understand what data is already being collected, where there are duplicates, and which actions actually need to be sent to GA4, Google Ads, or Meta.

The help of a specialist is especially justified in the following cases:

  • The site uses multiple analytics and advertising systems, and the team isn't sure which tags are installed directly, through the CMS, or through GTM.
  • You need to set up e-commerce with the correct products, price, currency, and transaction_id for each purchase.
  • Forms are powered by AJAX, React, or custom scripts, so standard submit triggers produce inconsistent results.
  • A Data Layer is required, and the developer needs to prepare a clear technical specification with a list of events and parameters.
  • Data in GA4, CRM, and advertising accounts is inconsistent, duplicate events are occurring, or some requests are not being recorded at all.
  • You need to link GA4, Google Ads, and Meta Pixel, check old conversions, and organize the tag structure into a clear format.

After configuration, it's a good idea to save the event table, tag names, and identifiers used. This documentation simplifies future changes and reduces the risk of accidentally breaking your analytics.

The terms "Google Tag Service" and "Google Tag Services" sometimes appear in search results, but Google Tag Manager and Google Tag are used for the task described. When implementing, it's best to rely on specific service names and IDs to avoid confusing different elements of the Google ecosystem.

Triggers

A trigger determines when a tag is fired. This can be a page load, a link click, a button press, a form submission, scroll depth, an element appearing on the screen, or a user event sent via the Data Layer.

For simple actions, GTM's built-in triggers are often sufficient. For example, a click on a phone number can be tracked using the Click URL value, which begins withtel:, and visiting the thank you page - by Page URL with the required part of the address.

The more precise the trigger conditions, the lower the risk of false positives. Checking only the button text can result in errors after design changes, so if you have a stable ID, class, or Data Layer event, it's better to use a more reliable indicator.

Variables

Variables store values that GTM retrieves from a page or data layer. Built-in variables can pass the page URL, link address, Click ID, Click Classes, Click Text, and other parameters of the current action.

Custom variables are used when the standard set is insufficient. For example, you can retrieve the order price, currency, product ID, form name, or internal user ID from the Data Layer and then pass these parameters to the event tag.

A variable helps make a single tag universal for several similar actions. Instead of creating separate tags for each page, you can pass a variable parameter value and keep the container structure compact and understandable.

Who needs GTM setup?

GTM is especially useful for websites that use multiple analytics and advertising systems. If a company runs Google Ads and Meta Ads, and tracks inquiries, calls, and purchases, managing tags through a container is usually more convenient than constantly changing website templates.

Online stores need GTM to set up e-commerce and transmit view_item, add_to_cart, begin_checkout, and purchase events. Service websites often need to track form submissions, phone and messenger clicks, and other elements related to customer interactions.

If a small site only requires basic Google Analytics 4 without additional events or advertising integrations, direct Google tag installation is possible. The choice depends on the goals, the number of tags, and plans for further analytics development.