Loading tutorials…
Loading tutorials…
GTM is the right install path for any site that runs more than one tracking pixel. It's also where most DIY installs go sideways — wrong trigger, wrong variable, wrong fire order. Here's the path that actually works.
Who this is forOwners installing GA4 on a site that already runs (or will run) Meta Pixel, TikTok Pixel, LinkedIn Insight Tag, or conversion linkers. If you're on a single-channel ad stack with no foreseeable expansion, the direct gtag.js install in the from-scratch tutorial is enough. Otherwise, this is the path.
What you'll need
Step 1
Sign in at tagmanager.google.com. Create an Account (business level) and a Container (site level).
Go to tagmanager.google.com. Click Create Account.
Account Name = business name. Country = where the business operates. Container Name = your website URL (e.g., acme.com). Target Platform = Web.
Accept the Terms of Service. You'll see two snippets: one for <head>, one for <body>. Both must go on every page of your site.
Install paths: for direct edits, paste both snippets into your site's master template. For Shopify, use the Customer Events sandbox or a GTM-enabled theme. For WordPress, Site Kit by Google handles this. For Webflow, Project Settings → Custom Code → Header/Footer.
Use the Tag Assistant Chrome extension or visit your site with the GTM Preview mode (top-right of the GTM interface) to confirm the container loads.
Step 2
In GTM, create a new tag of type "Google Tag" with your GA4 Measurement ID. This is the new (post-2024) name for the gtag.js install.
In GTM, go to Tags → New. Click the tag-configuration panel.
Select Google Tag from the list (formerly called "Google Analytics: GA4 Configuration" — Google renamed it in late 2023).
Enter your Measurement ID (G-XXXXXXXXXX). Leave the configuration settings at defaults unless you have specific reasons to change them.
Set the trigger to All Pages (Initialization - All Pages is even better for ensuring GA4 fires before other tags). Save the tag with a clear name like "GA4 - Google Tag."
Submit and publish the container (top-right blue button → Submit → Publish). Until you publish, the tag doesn't fire in production — only in Preview mode.
Step 3
Use GTM Preview mode + GA4 DebugView together. Both should show page views within 60 seconds.
In GTM, click Preview (top-right). Enter your site URL and click Connect. A new browser tab opens with a debug bar at the bottom — that's the GTM debugger.
Navigate around your site in the debug tab. In the GTM debugger, you should see "Google Tag" firing under each page load event.
Simultaneously, in GA4 → Admin → DebugView, you should see the same session with page_view events appearing in real time.
If GTM Preview shows the tag firing but DebugView is empty, the Measurement ID is wrong or the GA4 property is the wrong one. Double-check.
If GTM Preview shows the tag NOT firing, the trigger is wrong (most common: trigger set to Some Pages instead of All Pages).
Step 4
For ecommerce or lead-gen events, push to dataLayer from your site code, then create GTM triggers that listen for those pushes and fire GA4 Event tags.
The dataLayer is a JavaScript array that GTM listens to. You push events into it from your site code. Example for a purchase: dataLayer.push({event: 'purchase', ecommerce: {transaction_id: '1234', value: 50.00, currency: 'USD', items: [...]}})
In GTM → Triggers → New. Choose Custom Event. Event name = purchase (exact match to what you push). Save.
In GTM → Tags → New. Choose Google Analytics: GA4 Event. Configuration Tag = the Google Tag you created in Step 2. Event Name = purchase. Add event parameters: transaction_id = {{DLV - transaction_id}}, value = {{DLV - value}}, currency = {{DLV - currency}}, items = {{DLV - items}}.
DLV (Data Layer Variable) variables are created in GTM → Variables → User-Defined Variables → New → Data Layer Variable. Variable name = transaction_id, ecommerce.transaction_id, etc.
Repeat for view_item, add_to_cart, begin_checkout, add_payment_info, purchase. The exact dataLayer schema is in the GA4 documentation under "Recommended events."
Step 5
Add a Conversion Linker tag in GTM. This preserves GCLID and Floodlight data across redirects and subdomains.
In GTM → Tags → New. Choose Conversion Linker.
Leave defaults. Trigger = All Pages.
Save and publish.
Why this matters: Conversion Linker stores GCLID, DCLID, and other Google ad-click IDs in a first-party cookie. Without it, attribution gets lost on cross-domain redirects (e.g., shop.acme.com → checkout.acme.com), and Enhanced Conversions for Google Ads doesn't work.
If you only run GA4 and no Google Ads, Conversion Linker is still recommended — it protects you for the day you do start running Google Ads.
Step 6
Form submits, button clicks, scroll depth, video plays — each gets its own GTM trigger + Event tag pair.
Form submit example: GTM → Triggers → New → Form Submission. Enable Wait for Tags + Check Validation. Trigger fires on All Forms or specific form (use built-in variables like {{Form ID}} or {{Form Classes}} to scope).
Then GTM → Tags → New → Google Analytics: GA4 Event. Event Name = generate_lead. Parameters = form_id, form_name, etc. Trigger = the form submission trigger.
Button click example: enable Click variables in GTM → Variables → built-ins. Then create a trigger on Just Links or All Elements with a filter (e.g., Click Classes contains "cta-button").
Scroll depth, file download, video engagement, and outbound link clicks are auto-fired by GA4 Enhanced Measurement (covered in tutorial 1). You don't need to recreate them in GTM unless you need custom parameters.
Step 7
For every event you build, run a real test session in GTM Preview + DebugView and verify the event fires with correct parameters.
GTM Preview mode + GA4 DebugView, side by side.
For each event you set up, trigger it on your live site (submit a form, complete a purchase, click the CTA button).
In GTM debugger, confirm the trigger fired and the tag fired. In DebugView, confirm the event appears in GA4 with all expected parameters populated.
If parameters are missing or "(not set)", the Data Layer Variable mapping is wrong or the dataLayer push doesn't include that key.
Only after every event passes both checks should you click Publish on the container. Publishing untested tags is how production tracking breaks silently.
Common mistakes
Installing both GTM and direct gtag.js
What goes wrong: GA4 fires twice on every page. Sessions look 2x reality. Bid strategies optimize toward inflated conversion counts. Most accounts catch this after 30+ days of wasted spend.
How to avoid: Pick ONE install method. If GTM is on the site, remove any direct gtag.js snippet from templates. Verify with DebugView showing exactly one page_view per page load.
Forgetting to publish the GTM container
What goes wrong: Everything works in Preview mode. You declare victory. A week later you check GA4 — zero data. Because Preview is local-only; Publish is what makes tags fire for real visitors.
How to avoid: Always click Submit → Publish after testing. The version number in the top bar should increment. Verify production by browsing your site in a clean incognito tab and watching DebugView.
Wrong dataLayer event names
What goes wrong: You push "Purchase" (capital P) or "complete_purchase" instead of GA4's recommended "purchase". GA4 logs the event but doesn't recognize it as ecommerce. Reports show $0 revenue. Smart Bidding has no signal.
How to avoid: Use the GA4 recommended event names exactly: page_view, view_item, add_to_cart, begin_checkout, add_payment_info, purchase, sign_up, generate_lead. Lowercase, exact spelling.
Skipping the Conversion Linker
What goes wrong: GCLID gets stripped on cross-domain redirects. Google Ads attribution disappears for 20-40% of traffic that crosses subdomains. Enhanced Conversions stops working.
How to avoid: Add a Conversion Linker tag with All Pages trigger. Set and forget. 30 seconds of setup prevents months of attribution loss.
Not creating Data Layer Variables for event parameters
What goes wrong: Purchase events fire but transaction_id, value, and currency show as (not set) in GA4. You can't calculate ROAS. You can't filter reports by transaction.
How to avoid: For every parameter you push to dataLayer (transaction_id, value, currency, items), create a corresponding Data Layer Variable in GTM. Reference it in the Event tag's parameters.
Recap
Done — what's next
How to set up Google Analytics 4 from scratch
Read the next tutorial
Hand it off
GTM done right is the foundation for every other tracking decision — Google Ads conversions, Meta CAPI, TikTok events. Done wrong, it pollutes every report for months. A vetted GA4 + GTM specialist on EverestX typically charges $300-700 for a complete install + event setup + audit, at $14-16/hr.
See specialist rates
Use GTM if you'll ever run more than GA4 — Meta Pixel, TikTok Pixel, LinkedIn Insight Tag, conversion linkers, Hotjar, etc. Use direct gtag.js only for single-purpose installs where you're certain the stack won't expand. Most professional setups are GTM.
Same thing, renamed. Google rebranded "GA4 Configuration" to "Google Tag" in late 2023 as part of the broader gtag.js unification. The tag works identically — it just sets up the GA4 measurement on the page.
Yes if your platform doesn't do it automatically. Shopify (via the Google channel) and WooCommerce (via plugins) auto-push the standard ecommerce dataLayer. For custom-built sites, your developer needs to push the events using the GA4 recommended event schema.
Use the built-in Form Submission trigger with Wait for Tags + Check Validation enabled. If your form doesn't fire the trigger (common for AJAX forms), have your developer add a dataLayer.push({event: 'form_submit', form_id: 'contact'}) on submit success and create a Custom Event trigger.
Yes. Add a second Google Tag with the second property's Measurement ID. This is common for parent companies tracking multiple sub-brands in separate properties — but it doubles the tag-firing overhead, so only do it if you have a real reason.
Google Analytics 4
GA4 isn't hard to install — it's hard to install *correctly* so the data is actually usable six months from now. This is the walkthrough that prevents the rebuild most owners do at month four.
Google Analytics 4
Ecommerce tracking in GA4 isn't optional — it's the foundation of every revenue report, ROAS calculation, and ad-platform optimization decision. Done right it pays back forever. Done wrong it produces numbers that everyone in the org argues about for months.
Google Analytics 4
GA4 renamed Conversions to Key Events in late 2024. The name change matters less than what most owners get wrong: marking too many things as Key Events, which destroys Smart Bidding and inflates every report.
Google Analytics 4
DIY GA4 is a great idea — until it isn't. This is the honest framework: when the cost of unreliable data exceeds the cost of hiring help, and how to tell which side you're on.