Learning guide: GTM, GA4 and Google Ads conversions

Tracking your progress? The mastery checklist turns this guide into tick-off tasks, each with a "done when" test, plus a final project and a self-check quiz.

Work through the levels in order. Each one names the page to use, what the site already pushes, and what you build in GTM. Check every exercise in GTM Preview before you move on.

Visit as if from a Google ad

0. Set up

  1. Create a GTM account and a Web container at tagmanager.google.com. Copy its ID (GTM-XXXXXXX).
  2. Paste it in the box above (only your browser), or for every visitor open config.js and paste Google's whole <head> snippet between the backticks of GTM_LAB_TRACKING_CODE. Either way assets/gtm.js puts it on every page.
  3. Create a GA4 property with a Web data stream. Note the Measurement ID (G-XXXXXXX). Turn off enhanced measurement's form interactions so it does not muddy your own form tracking.
  4. Open a Google Ads account (a test or real one). You will create conversion actions in level 6.
  5. In GTM click Preview, enter this site's URL and connect. Keep the Tag Assistant tab next to the site tab.
  6. Open the dataLayer panel on the bottom right of every page. It lists every push as it happens, so you always know what GTM can see.
Localhost and Google Ads. Tags fire and can be debugged on localhost, but Google Ads only records conversions from real ad clicks. To see a conversion land in Ads, put the folder on a real domain (any static host such as Netlify Drop or GitHub Pages works) and click your own ad once, or use the gclid link above to test the cookie side.

1. Foundations

Pages: any. Pushed for you: the page_data event at the top of every page, before GTM loads.

{ event: "page_data", page_type: "product", site_section: "shop",
  login_status: "guest", user_id: undefined, customer_type: "new" }
Exercise 1.1
Add a Google tag with your GA4 Measurement ID, triggered on Initialization - All Pages. In Preview, see it fire on Initialization and check GA4 DebugView for page_view.
Exercise 1.2
Enable every built-in variable for Clicks, Forms, History, Videos, Scrolling, Visibility and Pages (Variables → Configure).
Exercise 1.3
Create Data Layer Variables DLV - page_type, DLV - login_status, DLV - user_id. Add them to the Google tag as configuration parameters (page_type) and as the user_id field. Register page_type as a custom dimension in GA4. Sign in on the account page and watch user_id appear.
Exercise 1.4
Find out why page_data shows up before gtm.js in Preview, and why a tag triggered on page_data would need a Custom Event trigger, not Page View.

2. Clicks and links

Pages: Home, Contact, Journal, footer on every page. Pushed for you: nothing. Use GTM's click triggers.

Exercise 2.1 · CTA buttons
Track Shop now and Get a bulk quote on the home page as a GA4 event cta_click. Trigger: Click - Just Links, Click ID equals hero-shop. Then make it generic: Click Element matches CSS selector [data-cta], [data-cta] *, and a DOM-free Custom JavaScript variable that returns {{Click Element}}.closest('[data-cta]').dataset.cta as the parameter cta_name.
Exercise 2.2 · The tricky four
The "Buttons to practise click triggers on" box on the home page has: a button with an ID, one with only a class, a link with a nested icon (click the dot and compare Click Element with Click Text) and a div that is not a link at all (only All Elements sees it).
Exercise 2.3 · Phone, email, WhatsApp
Three triggers on Just Links: Click URL starts with tel:, starts with mailto:, contains wa.me. Send them to GA4 as click_to_call, click_email, click_whatsapp. These become Google Ads conversions in level 6.
Exercise 2.4 · Outbound links and downloads
Outbound: Click URL Hostname does not equal {{Page Hostname}} and does not start with tel/mailto. Download: Click URL ends with .pdf (the catalogue in the footer and in the article). Send file_name from a URL variable (component: Path).

3. Forms

Pages: Contact (one step), Bulk quote (four steps), Account (sign up), footer newsletter. Pushed for you:

EventWhenUseful keys
form_startFirst focus or typing in a formform_id, form_name, first_field
form_errorSubmitted with problemserror_field, error_count, form_step_number
form_stepEach quote step shownform_step_number, form_step_name, step_direction
form_step_completeA quote step passes validationform_step_number
form_back / form_abandonBack button / tab hidden before sendingfrom_step, form_step_number
generate_leadContact or quote sentlead_type, lead_id, value, currency, gclid, user_data
sign_up, newsletter_signupAccount created, footer subscriptionmethod, user_id, user_data
Exercise 3.1 · Two ways to count a lead
Make a Form Submission trigger for contact-form with "Check validation" off, and a Custom Event trigger on generate_lead. Submit the form empty. The first fires, the second does not. That is why sites push their own event.
Exercise 3.2 · Funnel
One GA4 event tag, event name form_step, parameter form_step_number. Then build a funnel exploration in GA4: step 1 → 2 → 3 → 4 → generate_lead.
Exercise 3.3 · AJAX form
The footer newsletter never leaves the page. Track it with the newsletter_signup event, then try an Element Visibility trigger on #newsletter-ok as the fallback a site without a developer would use.
Exercise 3.4 · eventCallback
Lead forms push with eventCallback and redirect only after GTM reports its tags fired (see assets/forms.js). Remove your container (?gtm=off) and the form still redirects thanks to the fallback timer. Ask yourself what would happen without it.

4. Engagement

Page: Journal article, any product, quote. Pushed for you: nothing.

Exercise 4.1 · Scroll depth
Scroll Depth trigger, vertical 25, 50, 75, 90 percent, only on page_type equals article. Send percent_scrolled from {{Scroll Depth Threshold}}.
Exercise 4.2 · YouTube
YouTube Video trigger: Start, Complete, Pause, Progress 10/25/50/75/90. One GA4 tag named video_{{Video Status}} with video_title and video_percent.
Exercise 4.3 · Element visibility
Fire offer_view when #end-offer is 50% visible for 1 second, once per page. Then click "Load more articles" and try to catch #more-3: it only works with Observe DOM changes.
Exercise 4.4 · Timer
A Timer trigger, interval 30000 ms, limit 1, on the article page: engaged_30s.
Exercise 4.5 · History change
Product tabs (Details, Reviews, Shipping) change the URL with pushState. A History Change trigger with {{New History Fragment}} / {{Page URL}} sends a virtual page_view or tab_view. On the quote form, notice that the hash change and form_step both fire. Pick one source.
Exercise 4.6 · FAQ and anchors
Track the FAQ toggles in the article (Click Element matches summary) and the contents links (Click URL contains #).

5. GA4 ecommerce

Pages: Home → Shop → Product → Cart → Checkout → Thank you. Every event uses the GA4 schema and is preceded by { ecommerce: null }.

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: "add_to_cart",
  ecommerce: {
    currency: "INR", value: 2499,
    items: [{ item_id: "LS-101", item_name: "Arc Desk Lamp", item_brand: "Lumen",
              item_category: "Home Office", item_category2: "Lighting",
              item_variant: "Matte Black", price: 2499, quantity: 1 }]
  },
  add_method: "product_page"
});
Exercise 5.1 · One tag for all of them
Trigger: Custom Event, use regex matching:
^(view_item_list|select_item|view_item|add_to_cart|remove_from_cart|view_cart|begin_checkout|add_shipping_info|add_payment_info|purchase|view_promotion|select_promotion|add_to_wishlist)$
Tag: GA4 Event, Event Name {{Event}}, More Settings → Send Ecommerce data → Data source: Data Layer.
Exercise 5.2 · Extra parameters
Add payment_type to add_payment_info and shipping_tier to add_shipping_info (they live inside ecommerce, so the DLV name is ecommerce.payment_type). Add add_method to add_to_cart.
Exercise 5.3 · The whole path
Buy two items with coupon GTM10. In DebugView check every step, then the Monetisation reports a day later. Try Buy now on a product (skips the cart), quick add from the list (has item_list_name), and the out-of-stock headphones (back_in_stock_request).
Exercise 5.4 · Lists and promotions
Open a product from the home page, from search (?q=bottle) and from "You may also like". The product's view_item and add_to_cart carry the list it came from.

6. Google Ads conversions

  1. In Google Ads: Goals → Conversions → New conversion action → Website. Add it manually, choose a category (Purchase, Submit lead form, Phone call lead, Contact), and pick Use Google Tag Manager. Copy the Conversion ID and Conversion Label.
  2. In GTM add a Conversion Linker tag on All Pages. It stores the gclid from the ad click in a first-party cookie (_gcl_aw).
  3. Keep your Conversion ID in a Constant variable; labels differ per action.
Conversion actionTriggerValueTransaction ID
PurchaseCustom Event purchase{{DLV - ecommerce.value}}, currency {{DLV - ecommerce.currency}}{{DLV - ecommerce.transaction_id}}
Contact leadCustom Event generate_lead, lead_type equals contact{{DLV - value}}{{DLV - lead_id}}
Bulk quotegenerate_lead, lead_type equals bulk_quote{{DLV - value}} (estimate){{DLV - lead_id}}
Phone clickJust Links, Click URL starts with tel:fixed, e.g. 200none
WhatsApp clickJust Links, Click URL contains wa.mefixednone
Sign-up (secondary)Custom Event sign_upnone{{DLV - user_id}}
Exercise 6.1 · Purchase with cart data
In the purchase conversion tag, tick Provide product-level sales data, data source Data Layer. Google Ads then reads ecommerce.items for Shopping and Performance Max reporting.
Exercise 6.2 · Duplicate protection
Reload the thank-you page: the site does not push purchase again. Press "Fire purchase again" and it does. Google Ads and GA4 drop the second one because the transaction_id matches. Remove the Transaction ID field and see why it matters.
Exercise 6.3 · The gclid
Click "Visit as if from a Google ad" at the top of this page, accept cookies and look for _gcl_aw in DevTools → Application → Cookies. Then reject cookies (Cookie settings in the footer) and repeat: with Consent Mode the gclid is passed in link URLs instead (url_passthrough).
Exercise 6.4 · Remarketing
A Google Ads Remarketing tag on view_item, add_to_cart and purchase, with dynamic remarketing event data from the data layer. Primary conversions should be few: purchase and the two lead types. Mark clicks as secondary.

7. Enhanced conversions

Lead and purchase events carry the customer's details in the shape Google expects. Google hashes them in the browser before sending.

user_data: {
  email: "asha@example.com",
  phone_number: "+919876543210",
  address: { first_name: "Asha", last_name: "Rao", street: "12 MG Road",
             city: "Pune", region: "Maharashtra", postal_code: "411001", country: "IN" }
}
  1. Google Ads: Goals → Settings → Enhanced conversions for web → on, method Google Tag Manager. Accept the customer data terms.
  2. In each Google Ads conversion tag tick Include user-provided data from your website → New variable → User-Provided Data.
  3. Choose Manual configuration and map Email to {{DLV - user_data.email}}, Phone to {{DLV - user_data.phone_number}}, and the address fields to user_data.address.*. Or choose Code and point it at a single DLV user_data, which is already in the right format.
  4. In Preview, the conversion tag's details show the user-provided data was collected. In Ads, diagnostics appear after a few days of real traffic.
For GA4, set user_data on the Google tag using a User-Provided Data variable as well, if you use GA4 user-provided data collection. Never send email or phone as an ordinary GA4 event parameter: that is personal data in plain text.

8. Consent Mode v2

assets/gtm.js sets every Google consent type to denied before the container loads, then applies any earlier choice. The banner calls gtag('consent', 'update', …) and pushes consent_update.

Exercise 8.1
In Preview, open the Consent tab for each event. Compare the "On-page Default" with the "On-page Update" after you click Accept, Reject and Choose.
Exercise 8.2
Reject everything, then look in DevTools → Network for requests to collect. They still go out (Advanced consent mode) but without cookies, and with a gcs=G100 parameter. Accept and see gcs=G111.
Exercise 8.3
For a non-Google tag (say a Custom HTML pixel) set Additional consent checks → require ad_storage. Add a trigger on consent_update so it fires the moment someone accepts, not on the next page.
Exercise 8.4
Switch to Basic mode: block GA4 and Ads tags entirely until consent is granted. Note what you lose in GA4's modelled data.

9. Variable power-ups

  • Lookup Table: {{DLV - page_type}} → a content group (product, category → "Shop"; article → "Content").
  • RegEx Table: map {{Page Path}} to funnel stage names.
  • URL variable: query key q on the shop page, query key order_id on the thank-you page.
  • Custom JavaScript: number of units in the cart: function(){ var e = {{DLV - ecommerce.items}} || []; return e.reduce(function(s,i){return s + (i.quantity||1);},0); }
  • DOM Element: the SKU on a product page (#sku), the order total on the thank-you page (#order-total, attribute data-value). Learn why scraping the DOM is the last resort.
  • 1st-Party Cookie: read _gcl_aw.
  • Trigger groups: fire engaged_shopper only after a view_item and a 50% scroll on the same page.
  • Data Layer Version 1 vs 2: push a nested object twice and compare.

10. QA and common mistakes

MistakeWhere to reproduce it
Items from one event appear in the nextRemove the ecommerce: null push in assets/site.js and watch DebugView.
Purchase counted twiceThank-you page, "Fire purchase again", without a Transaction ID.
A lead counted twiceUse both the generate_lead event and the thank-you.html?type=lead page view.
Form trigger fires on invalid formsContact page, empty submit.
Tag needs a value that is not there yetTrigger on Page View and read ecommerce.value: it is undefined until the event happens.
Click trigger misses nested elementsHome page, the icon in "Link with a nested icon".
Nothing firesNo container: the dataLayer panel says so. Ad blockers block GTM too.

Before publishing: name tags Platform - Type - Detail (e.g. GA4 - Event - add_to_cart), write a version note, and use a separate workspace per change.

Event reference

EventPageKey fields
page_dataevery page, firstpage_type, site_section, login_status, user_id, customer_type
consent_updatebannerconsent_method, consent_analytics, consent_ads
view_promotion, select_promotionhomeecommerce.promotion_id, promotion_name, creative_name, creative_slot, items
view_item_list, select_itemhome, shop, product (related)ecommerce.item_list_id, item_list_name, items[].index
search, search_no_resultsshop with ?q=search_term, search_results
filter_apply, sort_applyshopfilter_type, filter_value, sort_value
view_itemproductecommerce.value, items, stock_status
select_variant, add_to_wishlist, shareproductitem_variant, method
back_in_stock_requestout-of-stock productitem_id, user_data
add_to_cartshop, product, cartecommerce.value, items, add_method
remove_from_cart, view_cartcartecommerce.value, items
coupon_applycartcoupon, coupon_status
begin_checkoutcheckout loadecommerce.value, coupon, items
checkout_stepcheckoutcheckout_step, checkout_step_name
add_shipping_infocheckout step 2ecommerce.shipping_tier
add_payment_infocheckout step 3ecommerce.payment_type
purchasethank you (order)ecommerce.transaction_id, value, tax, shipping, coupon, items; new_customer, user_data
purchase_already_trackedthank you, on reloadtransaction_id
form_start, form_error, form_step, form_step_complete, form_back, form_abandoncontact, quote, account, checkoutform_id, form_name, form_step_number
generate_leadcontact, quotelead_type, lead_id, value, currency, gclid, user_data
thank_you_viewthank you (lead, quote, signup)lead_type, lead_id, value, user_data
sign_up, login, logoutaccountmethod, user_id
newsletter_signupfootermethod, user_data

Test values

  • Coupons: GTM10 (10%) and ADS20 (20%). Anything else is rejected and pushes coupon_status: invalid.
  • Out of stock: Studio Headphones. On sale: Commuter Backpack.
  • Free shipping over ₹1,500, express ₹149.
  • No such product: product.html?id=nope pushes page_not_found.
  • Ad click: add ?gclid=TEST-GCLID-123&utm_source=google&utm_medium=cpc to any URL. Leads then carry the stored gclid.
  • Container: ?gtm=GTM-XXXX to switch, ?gtm=off to unload.