If you can't say how many leads your website sent you last month, you're guessing about the one marketing asset you fully own. The fix is to set up Google Tag Manager and Google Analytics 4 so every form fill and phone tap gets counted.
This is fiddly work. Lots of clicking, lots of settings with similar names. That makes it a good job for an AI agent driving the browser while you, or someone you trust, makes the decisions and checks the result.
Here's the walkthrough, in order, with a prompt for the agent at each stage.
What you're building, in plain English
Three pieces:
- GA4 is Google's free analytics tool. It records what visitors do.
- Google Tag Manager (GTM) is a container on your site that holds tracking code. You add and change tracking in GTM's dashboard instead of editing your website.
- The generate_lead event is the signal "someone just became a lead." GA4 lists it as a >recommended event for when a visitor submits a form or a request for information.
Goal: every real lead sends generate_lead to GA4, and GA4 treats it as a key event.
Before you start: access, not passwords
You sign into Google yourself in the browser the agent will use. Don't paste passwords into a chat. If you can, add a separate Google user to GTM and GA4 with only the access the job needs.
And decide now: the agent builds and tests, a human publishes. Anything that goes live on your site gets a human yes. More on that in what I never let agents do unsupervised.
How do I set up Google Tag Manager on my site?
Step 1: Get your GA4 measurement ID
If you don't have a GA4 property, create one and add a web data stream for your site. Then find the >measurement ID under Admin, Data streams. It starts with "G-".
Step 2: Create the container and install the snippet
In Tag Manager, create an account and a web container. Google gives you two pieces of code. Per >Google's install guide, the first goes as high in the page's head as possible, and the second goes right after the opening body tag. Most website builders have a header code box or a plugin for this.
Step 3: Add the Google tag
In GTM, create a new tag, choose the Google Tag type, paste your G- ID, and set it to fire on initialization so it loads on every page. Google's >Google tag setup steps cover this.
Prompt: Audit, then install GTM and the Google tag
Goal: Get Google Tag Manager and GA4 installed correctly on [website URL] so we can track leads.
Context: I'm signed into Google Tag Manager, Google Analytics and [website platform] in this browser. Our GA4 measurement ID is [G-XXXXXXX].
Step 1, read only: Visit the site and tell me what tracking already loads (any GTM container IDs, any G- IDs, any old tracking code). Check whether the GTM snippet is in the head and right after the opening body tag.
Step 2: If GTM is not installed, show me exactly where you plan to add the snippet in [website platform] and wait for my OK.
Step 3: In GTM container [GTM-XXXXXXX], create a Google Tag with our G- ID firing on initialization for all pages.
Constraints: Do not publish the container. Do not delete or edit existing tags. If you hit a login, 2-step check or CAPTCHA, stop and tell me.
Done: A short list of what you found, what you changed, and anything that looked odd.
Track form submissions as generate_lead
This is where most small business tracking breaks.
If your form is part of your page
Many form plugins can push an event when a form succeeds, or send people to a thank-you page. Either works. A thank-you page lets you fire on a page view of that URL.
If your form is embedded from another company
A lot of CRMs and booking tools give you a form that loads in an iframe, a little window from their domain inside your page. Browsers keep the two walled off, so your page never sees the submit. GTM sits there waiting for something that never happens.
The fix: many embedded forms announce "I was submitted" to the page using a browser feature called >postMessage. A small listener on your page hears that message and pushes generate_lead into the dataLayer, which is the list of events GTM watches. Check your form vendor's docs for what their message looks like. If they don't send one, use a thank-you page redirect.
This isn't theory for me. This week I set up conversion tracking on two of my own sites with an agent driving the browser. Both lead forms were embedded from another domain. The agent spotted that one site had no listener at all, which is why conversions there had never recorded once. Adding a listener is the fix, and the prompt below asks the agent to check for one first.
Wire it up in GTM
- Create a Custom Event trigger named
generate_lead. Google's >custom event trigger guide shows how it matches a dataLayer push. - Create a Google Analytics: GA4 Event tag with your measurement ID and event name
generate_lead, as in Google's >GA4 event tag guide. - Attach the trigger to the tag.
Prompt: Track form submissions as generate_lead
Goal: Every successful lead form submission on [website URL] should send a generate_lead event to GA4.
Context: Our lead form is on [page URL]. I'm signed into GTM and the site in this browser. GTM container: [GTM-XXXXXXX]. GA4 ID: [G-XXXXXXX].
Step 1, read only: Tell me whether the form is part of the page or loads in an iframe from another domain. If it's an iframe, tell me the domain and check the vendor's help docs for a "form submitted" postMessage event.
Step 2: Propose the approach (listener, plugin event, or thank-you page). For a listener, write it to check the message origin is [vendor domain] and push {event: 'generate_lead'} to the dataLayer. Show me the code and where it will go before adding it.
Step 3: In GTM, create a Custom Event trigger named generate_lead and a GA4 Event tag named "GA4 - generate_lead" using that trigger.
Constraints: Do not publish. Do not submit the real form with fake data unless I say so. Stop and ask if anything is unclear.
Done: What you built, and how I can test it.
Track click-to-call too
For a lot of service businesses, the phone is the main lead source. Track taps on your phone number as their own event so you can tell calls from forms.
Create a click trigger using Just Links, set to fire on Some Clicks where Click URL starts with tel: (Google explains the options in its >click trigger guide). You may need to turn on the built-in Click URL variable first. Attach it to a GA4 Event tag with a name like click_to_call.
Test in Preview, then publish
Never publish blind. In GTM, click Preview, enter your site URL, and Google's >Tag Assistant opens your site connected to a debug view. Submit a test lead and tap your phone link, then confirm the right tags fired once each.
Prompt: Test the tracking in Preview
Goal: Confirm our GA4 tracking works before anything goes live.
Context: GTM container [GTM-XXXXXXX] has new tags for the Google tag, generate_lead and click_to_call. I'm signed in.
Steps: Start Preview mode for [website URL]. Load the home page and the contact page. Tap the phone link. I will submit one test lead myself when you tell me you're ready.
Done: A table showing each tag, whether it fired, how many times, and on which page. Flag anything that fired twice or not at all.
Constraints: Do not publish. Do not submit any forms yourself.
When the test looks right, a human clicks Submit, names the version ("Added generate_lead and click_to_call"), and publishes. GTM keeps old versions if you ever need to roll back.
Mark generate_lead as a key event
Last step. In GA4, go to Admin, then Data display, then Events, and star generate_lead to >mark it as a key event. If it hasn't shown up yet, Google lets you mark it ahead of time. It only counts from that day forward.
If you run Google Ads, that same event can feed an Ads conversion. That's a separate setup, but it all starts here.
Frequently asked questions
Do I need Google Tag Manager if I already have GA4?
Not strictly, but it makes life easier. GA4 alone will count page views. Tag Manager gives you one place to add lead tracking, call clicks and future tags without editing your site code every time. It's also easier for an agent to work in one dashboard than to edit theme files.
Why aren't my form submissions showing up in GA4?
The most common reason I see is an embedded form from another company's domain. Your page can't see inside that frame, so nothing fires. The fix is a small listener that hears the form's submitted message and pushes a generate_lead event, or a redirect to a thank-you page you can track instead.
Is it safe to let an AI agent work in Tag Manager?
It's safe if you set it up right. Sign in yourself, give the agent a user with only the access it needs, and don't let it publish. Tag Manager keeps every published version, so a human reviews the changes in Preview and publishes, and a bad version can be rolled back.
What's a key event in GA4?
It's an event you've told GA4 matters to the business, like a lead. Marking generate_lead as a key event makes it show up in the reports where you measure results. It only counts from the day you mark it, not backward.
Want this done and checked for you?
Lead tracking is one of the first things I fix, because every other decision depends on it. My agents do the clicking, I review every tag before anything publishes, and we go over the numbers weekly. Try the first month for $99.



