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.
0. Set up
- Create a GTM account and a Web container at tagmanager.google.com. Copy its ID (
GTM-XXXXXXX). - Paste it in the box above (only your browser), or for every visitor open
config.jsand paste Google's whole<head>snippet between the backticks ofGTM_LAB_TRACKING_CODE. Either wayassets/gtm.jsputs it on every page. - 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. - Open a Google Ads account (a test or real one). You will create conversion actions in level 6.
- In GTM click Preview, enter this site's URL and connect. Keep the Tag Assistant tab next to the site tab.
- 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, 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" }
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.Enable every built-in variable for Clicks, Forms, History, Videos, Scrolling, Visibility and Pages (Variables → Configure).
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.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.
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.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).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.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:
| Event | When | Useful keys |
|---|---|---|
form_start | First focus or typing in a form | form_id, form_name, first_field |
form_error | Submitted with problems | error_field, error_count, form_step_number |
form_step | Each quote step shown | form_step_number, form_step_name, step_direction |
form_step_complete | A quote step passes validation | form_step_number |
form_back / form_abandon | Back button / tab hidden before sending | from_step, form_step_number |
generate_lead | Contact or quote sent | lead_type, lead_id, value, currency, gclid, user_data |
sign_up, newsletter_signup | Account created, footer subscription | method, user_id, user_data |
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.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.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.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.
Scroll Depth trigger, vertical 25, 50, 75, 90 percent, only on
page_type equals article. Send percent_scrolled from {{Scroll Depth Threshold}}.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.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.A Timer trigger, interval 30000 ms, limit 1, on the article page:
engaged_30s.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.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"
});
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.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.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).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
- 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.
- 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). - Keep your Conversion ID in a Constant variable; labels differ per action.
| Conversion action | Trigger | Value | Transaction ID |
|---|---|---|---|
| Purchase | Custom Event purchase | {{DLV - ecommerce.value}}, currency {{DLV - ecommerce.currency}} | {{DLV - ecommerce.transaction_id}} |
| Contact lead | Custom Event generate_lead, lead_type equals contact | {{DLV - value}} | {{DLV - lead_id}} |
| Bulk quote | generate_lead, lead_type equals bulk_quote | {{DLV - value}} (estimate) | {{DLV - lead_id}} |
| Phone click | Just Links, Click URL starts with tel: | fixed, e.g. 200 | none |
| WhatsApp click | Just Links, Click URL contains wa.me | fixed | none |
| Sign-up (secondary) | Custom Event sign_up | none | {{DLV - user_id}} |
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.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.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).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" }
}
- Google Ads: Goals → Settings → Enhanced conversions for web → on, method Google Tag Manager. Accept the customer data terms.
- In each Google Ads conversion tag tick Include user-provided data from your website → New variable → User-Provided Data.
- Choose Manual configuration and map Email to
{{DLV - user_data.email}}, Phone to{{DLV - user_data.phone_number}}, and the address fields touser_data.address.*. Or choose Code and point it at a single DLVuser_data, which is already in the right format. - 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.
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.
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.
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.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.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
qon the shop page, query keyorder_idon 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, attributedata-value). Learn why scraping the DOM is the last resort. - 1st-Party Cookie: read
_gcl_aw. - Trigger groups: fire
engaged_shopperonly after aview_itemand 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
| Mistake | Where to reproduce it |
|---|---|
| Items from one event appear in the next | Remove the ecommerce: null push in assets/site.js and watch DebugView. |
| Purchase counted twice | Thank-you page, "Fire purchase again", without a Transaction ID. |
| A lead counted twice | Use both the generate_lead event and the thank-you.html?type=lead page view. |
| Form trigger fires on invalid forms | Contact page, empty submit. |
| Tag needs a value that is not there yet | Trigger on Page View and read ecommerce.value: it is undefined until the event happens. |
| Click trigger misses nested elements | Home page, the icon in "Link with a nested icon". |
| Nothing fires | No 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
| Event | Page | Key fields |
|---|---|---|
| page_data | every page, first | page_type, site_section, login_status, user_id, customer_type |
| consent_update | banner | consent_method, consent_analytics, consent_ads |
| view_promotion, select_promotion | home | ecommerce.promotion_id, promotion_name, creative_name, creative_slot, items |
| view_item_list, select_item | home, shop, product (related) | ecommerce.item_list_id, item_list_name, items[].index |
| search, search_no_results | shop with ?q= | search_term, search_results |
| filter_apply, sort_apply | shop | filter_type, filter_value, sort_value |
| view_item | product | ecommerce.value, items, stock_status |
| select_variant, add_to_wishlist, share | product | item_variant, method |
| back_in_stock_request | out-of-stock product | item_id, user_data |
| add_to_cart | shop, product, cart | ecommerce.value, items, add_method |
| remove_from_cart, view_cart | cart | ecommerce.value, items |
| coupon_apply | cart | coupon, coupon_status |
| begin_checkout | checkout load | ecommerce.value, coupon, items |
| checkout_step | checkout | checkout_step, checkout_step_name |
| add_shipping_info | checkout step 2 | ecommerce.shipping_tier |
| add_payment_info | checkout step 3 | ecommerce.payment_type |
| purchase | thank you (order) | ecommerce.transaction_id, value, tax, shipping, coupon, items; new_customer, user_data |
| purchase_already_tracked | thank you, on reload | transaction_id |
| form_start, form_error, form_step, form_step_complete, form_back, form_abandon | contact, quote, account, checkout | form_id, form_name, form_step_number |
| generate_lead | contact, quote | lead_type, lead_id, value, currency, gclid, user_data |
| thank_you_view | thank you (lead, quote, signup) | lead_type, lead_id, value, user_data |
| sign_up, login, logout | account | method, user_id |
| newsletter_signup | footer | method, 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=cpcto any URL. Leads then carry the stored gclid. - Container:
?gtm=GTM-XXXXto switch,?gtm=offto unload.