Tracking
By Syncfusion®, Inc. · Last updated
Stage one is live in a day: the conversion tag, GA4, UTMs and consent. Stage two sends CRM outcomes back as offline conversions.
What you will learn
- Add the Google tag and a conversion to your key forms
- Handle consent for EU and UK visitors
- Send CRM outcomes back as offline conversions
At a glance
Stage one can be live in a day: the Google tag on every page, one primary conversion action, GA4 linked, auto-tagging on, consistent UTMs, and the GCLID and UTMs saved with each lead. Fire the conversion when the lead is actually created (thank-you step), never on a button click. Consent comes first for EU/UK visitors: a consent banner sending Google Consent Mode v2 signals, defaulting to denied. Form fills aren't the result. Stage two sends CRM outcomes (qualified leads, opportunities, won deals) back into Google Ads with a CSV upload, so bidding learns what pipeline looks like. GA4 is the default because it links to Google Ads in minutes. Your CRM is the source of truth for pipeline.
The five things to understand
Conversion action
Something you tell Google Ads to count. You'll have one primary conversion (used for bidding) and maybe a few secondary ones (reported, not bid on).
Google tag
One script on every page that sends data to Google Ads and GA4. An event snippet fires the conversion.
Auto-tagging and GCLID
With auto-tagging on, Google adds gclid=... to every ad click's URL. Save it with the lead; it's the key that links a CRM outcome back to the click.
UTMs
Readable tags (utm_source=google&utm_medium=cpc&utm_campaign=...) that tell GA4 and your CRM where a visit came from. Use them alongside auto-tagging.
Offline conversion
An outcome that happens later, in your CRM (SQL, opportunity, closed deal), uploaded back to Google Ads.
Decide what to count
Demo request goal. Primary conversion at launch:
Demo request submitted. Counted once per lead ("One" counting). Fired on the thank-you page after the server accepted the form.
Secondary: contact-sales or pricing page form fills if you have them. Later (stage two), add SQL and Opportunity created as offline conversions and make SQL the primary for bidding once you upload enough of them.
Free trial goal. Primary conversion at launch:
Trial account created (not "sign-up form started"). Counted once per lead. Fired after the account exists. For example on the first in-app page or a confirmation page.
Secondary: email verified. Later (stage two), add Activated trial (reached your key product action) and Converted to paid as offline conversions, and make activation the primary once you upload enough of them.
Give conversions a value even at stage one, roughly what each is worth on average: value = average deal value × the share of these leads that become customers. If deals average $20,000 and 5% of demo requests close, each request is worth about $1,000. A rough value lets you move to value-based bidding later without restructuring.
Stage one: live in a day
Order matters If your region needs consent handling, set up the consent banner and Consent Mode defaults before the Google tag, so the first tag load already respects the visitor's choice. See Consent below.
1. Add the Google tag to the Astro base layout
In Google Ads, go to Goals, then Conversions, then Settings (or the Google tag screen) to find your tag ID (AW-XXXXXXXXX). In GA4, find the measurement ID (G-XXXXXXX).
Add both to the shared layout so every page loads the tag once. In Astro, inline scripts need is:inline so Astro leaves them as written.
src/layouts/BaseLayout.astro
---
// src/layouts/BaseLayout.astro (your site's shared layout)
const GOOGLE_ADS_ID = 'AW-XXXXXXXXX';
const GA4_ID = 'G-XXXXXXX';
---
<html lang="en">
<head>
<!-- Consent Mode defaults go here first if you need them (see Consent) -->
<script is:inline async src={`https://www.googletagmanager.com/gtag/js?id=${GA4_ID}`}></script>
<script is:inline define:vars={{ GOOGLE_ADS_ID, GA4_ID }}>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
window.gtag = gtag;
gtag('js', new Date());
gtag('config', GA4_ID);
gtag('config', GOOGLE_ADS_ID, { allow_enhanced_conversions: true });
</script>
</head>
<body><slot /></body>
</html>
2. Create the conversion action and fire it on success
In Google Ads: Goals, then Conversions, then New conversion action, then Website. Choose "Submit lead form" (demo) or "Sign-up" (trial) as the category, set the value, set counting to "One", and set it as primary.
Google gives you a send_to label like AW-XXXXXXXXX/AbCdEfGh. Fire it on the thank-you page:
src/pages/thank-you.astro
---
// src/pages/thank-you.astro (or the first page after a trial account is created)
---
<BaseLayout>
<h1>Thanks, we'll be in touch within one business day.</h1>
<script is:inline>
gtag('event', 'conversion', {
send_to: 'AW-XXXXXXXXX/AbCdEfGh',
value: 1000, // your average value per lead
currency: 'USD'
});
gtag('event', 'generate_lead'); // GA4 event, mark it as a key event in GA4
</script>
</BaseLayout>
Make sure the thank-you page is only reachable after a successful submission, and isn't linked anywhere else, or people who bookmark it will count as conversions.
3. Link GA4, turn on auto-tagging
In Google Ads, Tools, then Data manager (or Linked accounts): link the GA4 property. Turn on auto-tagging in Account settings (it's on by default for new accounts; check it).
In GA4, mark generate_lead (or sign_up) as a key event. You can import it into Google Ads as a secondary conversion for comparison; keep the Google Ads tag conversion as primary to avoid counting twice.
4. Consistent UTMs
Auto-tagging handles Google's own reporting; UTMs make the source readable in your CRM and other tools. Add one account-level Final URL suffix so every ad gets them automatically:
Final URL suffix
utm_source=google&utm_medium=cpc&utm_campaign={campaignid}&utm_content={adgroupid}&utm_term={keyword}
If you'd rather have readable campaign names, set the suffix at campaign level with the name written in (for example utm_campaign=us-search-core). Use lowercase and hyphens, always. The UTM builder enforces this.
5. Save the GCLID and UTMs with every lead
This is the step teams skip, and it is the one that makes stage two possible. Capture the values when the visitor lands, keep them for the session (people browse before converting), and send them in hidden form fields that map to CRM fields.
Astro / HTML
<!-- in your form component -->
<input type="hidden" name="gclid" />
<input type="hidden" name="utm_source" />
<input type="hidden" name="utm_medium" />
<input type="hidden" name="utm_campaign" />
<input type="hidden" name="utm_term" />
<input type="hidden" name="utm_content" />
<script is:inline>
(function () {
var keys = ['gclid', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content'];
var params = new URLSearchParams(location.search);
var stored = {};
try { stored = JSON.parse(localStorage.getItem('attribution') || '{}'); } catch (e) {}
// First touch wins within 90 days; a new ad click (new gclid) replaces it.
if (params.get('gclid') || !stored.ts || Date.now() - stored.ts > 90 * 864e5) {
var fresh = { ts: Date.now() };
keys.forEach(function (k) { if (params.get(k)) fresh[k] = params.get(k); });
if (Object.keys(fresh).length > 1) { stored = fresh; localStorage.setItem('attribution', JSON.stringify(stored)); }
}
document.querySelectorAll('form input[type=hidden]').forEach(function (input) {
if (stored[input.name]) input.value = stored[input.name];
});
})();
</script>
Create matching custom fields in your CRM (for example GCLID, UTM Source, UTM Campaign) and map the form fields to them. In the EU/UK, only store these after consent if your legal team treats them as tracking identifiers; your CMP can gate this script.
6. Turn on enhanced conversions for leads
In the conversion settings, turn on enhanced conversions for leads and choose the Google tag method.
(Google is merging enhanced conversions for web and for leads into one on/off setting, and since April 2026 accepts user-provided data from the tag, Data Manager and the API at the same time, so you may see a single "Enhanced conversions" switch instead.) The tag then sends a hashed copy of the email from the form with the conversion.
This is Google's recommended basis for later CRM uploads, because it matches leads even when the GCLID is lost.
The allow_enhanced_conversions line in the tag above enables it; Google can detect the email field automatically, or you can specify it. As of October 2026
Install stage-one tracking in our Astro site
7. Test it
Open your landing page with ?gclid=test123&utm_source=google&utm_medium=cpc&utm_campaign=test added.
Use Google Tag Assistant (tagassistant.google.com) to confirm the tag loads and the conversion event fires on the thank-you page.
Check the lead in your CRM has test123 and the UTM values.
In GA4, check DebugView or Realtime for the generate_lead event.
In Google Ads, the conversion status should move from "Unverified" to "No recent conversions" or "Recording conversions" within a day.
Consent and privacy for your region
This isn't legal advice; your legal or privacy team decides what you need. It's the practical version of what affects your tracking setup. As of October 2026
EU/UK (and Switzerland) Under GDPR, the ePrivacy rules and the UK's PECR, you need prior consent for non-essential cookies, including advertising and analytics tags. Google's EU user consent policy applies to users in the EEA, the UK and Switzerland, and Google requires Consent Mode v2 signals for that traffic. From 21 July 2025, Google began switching off conversion tracking, remarketing and personalisation for advertisers not sending those signals, according to its notices to affected accounts. If your account was caught, setting up Consent Mode restores measurement from then on. It does not bring back the data you missed. What you need:
A consent banner (CMP) that supports Consent Mode v2. Google-certified CMPs integrate directly; open-source options such as Klaro or Orestbida's CookieConsent work if you wire up the four signals yourself.
All four signals set to denied by default, before the Google tag loads, then updated when the visitor chooses.
Your privacy notice listing Google Ads, GA4 and any form protection services.
Astro / HTML
<!-- In the <head>, BEFORE the Google tag -->
<script is:inline>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
ad_storage: 'denied',
analytics_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
wait_for_update: 500
});
// Optional: default to granted outside the EEA/UK/CH, if your legal team agrees
// gtag('consent', 'default', { ad_storage: 'granted', ... , region: ['US'] });
</script>
<!-- Your CMP calls this when the visitor accepts -->
<script is:inline>
function onConsentAccepted() {
gtag('consent', 'update', {
ad_storage: 'granted',
analytics_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'granted'
});
}
</script>
The two v2 signals, ad_user_data and ad_personalization, are the ones most often missing. Check them in Tag Assistant: the consent tab shows the default and updated states.
Go deeper Basic vs advanced Consent Mode
In basic mode, Google tags don't load at all until consent is given. In advanced mode, tags load with consent denied and send cookieless pings, which Google uses to model conversions it can't observe. Advanced mode recovers more measurement; some legal teams prefer basic. Either is valid for Google's requirement. Ask your privacy team which you use, and write it down.
US/Canada
The US uses an opt-out model for most marketing tracking.
California (CCPA/CPRA) and a growing list of other states give people the right to opt out of "sale" or "sharing" of personal data, including for targeted advertising, and several require you to honour the Global Privacy Control (GPC) browser signal.
You don't need a pre-consent banner for US traffic in most states, but you do need a privacy notice that discloses advertising cookies and a working "Do not sell or share" mechanism.
In Canada, PIPEDA expects meaningful consent, usually satisfied by notice for analytics; Quebec's Law 25 requires opt-in consent for tracking technologies, so Quebec visitors need a consent banner.
Practical setup: a CMP that shows an opt-in banner where required (Quebec, and any EU/UK visitors) and an opt-out link elsewhere, honouring GPC.
Consent Mode defaults can be granted for US regions and denied for Quebec and the EEA using the region parameter.
India The Digital Personal Data Protection (DPDP) Act 2023 is in force, and the DPDP Rules were notified on 13 November 2025 with a phased rollout. The rules for registered consent managers start on 13 November 2026. The notice-before-consent rule (Rule 3) and most other obligations apply from 13 May 2027, 18 months after notification. The rules require consent that is free, specific and informed, with withdrawal as easy as giving consent. Practical setup now: a clear privacy notice covering advertising and analytics, and a consent banner for non-essential tags if your legal team wants to get ahead of the deadline (many do, since it's cheaper to build once). If you get EU/UK traffic, you need Consent Mode v2 for those visitors anyway.
Rest of APAC Rules differ a lot by country:
Australia: the Privacy Act (amended in late 2024, with more reforms expected) requires transparency about tracking; no blanket cookie-consent rule yet. Singapore: the PDPA requires notice and consent for collecting personal data, with some deemed-consent exceptions. Japan: the APPI, plus the Telecommunications Business Act's external transmission rule (since 2023), which requires you to notify users when tags send their data to third parties like Google. A clear cookie notice usually covers it. South Korea: PIPA is strict: explicit consent for collection and for overseas transfer. Treat Korea like the EU.
Practical setup: a CMP configured per country, opt-in for Korea (and EU/UK visitors), notice-based elsewhere.
Latin America
Brazil: the LGPD requires a legal basis for processing. The ANPD's cookie guidance says non-essential cookies such as advertising generally need consent, with a banner that makes rejection as easy as acceptance. Mexico: a new Federal Law on the Protection of Personal Data Held by Private Parties was published on 20 March 2025 and took effect the next day, replacing the 2010 law. Oversight moved from the INAI to the Secretaría Anticorrupción y Buen Gobierno. Privacy notices are mandatory, and secondary purposes such as advertising need a way to opt out. Chile: Law 21.719, published in December 2024, takes effect on 1 December 2026. It brings rules closer to GDPR and a new Personal Data Protection Agency that can impose fines. Argentina and Colombia have older but active data protection laws based on notice and consent.
Practical setup: an opt-in banner for Brazil (and Chile once in force), a clear notice with opt-out elsewhere, Spanish and Portuguese versions of both.
Middle East/Africa
South Africa: POPIA requires a lawful basis and notice; direct marketing rules are strict. Saudi Arabia: the PDPL has been enforced since September 2024 and generally requires consent, with restrictions on transfers abroad. UAE: the federal PDPL applies, and free zones such as DIFC and ADGM have their own GDPR-style laws. Nigeria (NDPA 2023), Kenya and others have consent-based laws with active regulators.
Practical setup: an opt-in consent banner is the safe default across the region. Check data transfer rules with your legal team, since Google tags send data abroad.
Re-checked 3 November 2026: consent changes in 2026
Since 15 June 2026, advertising data from the GA4 tag that is shared with a linked Google Ads account is controlled only by the Consent Mode ad_storage signal.
Google Signals no longer limits it and now only controls whether Analytics links data to signed-in users for its own reports.
Google has also said that, later in 2026, ad_personalization will become the only control over whether Analytics data is used for personalisation in Google Ads, and that IP addresses collected by the Google tag will be encrypted before they reach Google Ads.
Nothing in stage one changes: send all four Consent Mode signals from your consent banner. As of November 2026
GA4 or something else?
Use GA4 plus your CRM. GA4 links to Google Ads in a few clicks, imports conversions and audiences, and is free. The CRM is where pipeline lives, and it's what stage two reads from. That combination covers what B2B teams need from Google Ads tracking.
Open-source analytics tools such as PostHog (product and web analytics, self-hostable), Plausible or Umami (simple, privacy-friendly web analytics) are good, and some teams prefer them for privacy or product analytics. But none of them feeds Google Ads bidding, so they'd be in addition to the Google tag, not instead of it. If you already use one, keep it for site analytics; for the first week, GA4 is the fastest route to working ad tracking.
Stage two: send CRM outcomes back to Google Ads
Start this in month two Stage two needs a few weeks of leads with saved GCLIDs or emails. Start once stage one has been live for about a month.
Google's bidding only knows what you tell it. If it only sees form fills, it finds more form fills, including students and competitors. Once you upload which leads became SQLs, opportunities and customers, it can bid for the searches that produce pipeline.
Ad click gclid=Cj0K…
Form hidden gclid, email
CRM lead → SQL → won
CSV weekly export
Google Ads offline conversions
bidding learns which searches lead to pipeline
Replay Stage two data flow: the click ID or email travels with the lead, and outcomes flow back to Google Ads as a CSV upload.
Choose your method
As of October 2026
Google now recommends enhanced conversions for leads over the older GCLID-only import. You upload CRM outcomes keyed by the hashed email (and the GCLID if you have it), and Google matches them to the original click. It is more reliable because it still works when the GCLID wasn't captured.
CSV upload through Data Manager (in Google Ads: Tools, then Data manager) works with any CRM and is what this course uses. Upload a CSV by hand, or schedule imports from Google Sheets, HTTPS or SFTP. Google now labels the older file import under Conversions, then Uploads as legacy and says enhanced conversions for leads only supports Data Manager files, so start in Data Manager. When you create the import, pick the template for conversions from clicks (enhanced conversions for leads), which has the user-data columns. API integrations: since 15 June 2026, offline conversion and enhanced-conversions-for-leads uploads through the Google Ads API are blocked and must use the Data Manager API instead. This only matters if a developer or a connector tool uploads for you; check your connector has migrated. Uploading files through Data Manager in the interface isn't affected. Native CRM connectors (Salesforce, HubSpot and others link directly in Data Manager) are a good later improvement. They're quicker to maintain, but slower to set up than a CSV and need admin access on both sides.
Set it up
In Google Ads, create an offline conversion action for each CRM stage you'll upload, for example SQL and Closed won (or Trial activated and Converted to paid). Source: "CRM, files or other data sources". Set counting to "One". Keep them secondary at first. Once you're uploading a steady volume (as a rule of thumb, 15 to 30 a month for the stage you want to bid on), make that stage the primary conversion and set the website form fill to secondary. In your CRM, build a report: leads that reached the stage in the last 90 days, with GCLID, email, the date and time they reached the stage, and value. Export it weekly as CSV, transform it to Google's template (or let your LLM do it), and upload. Use the offline conversion template from this site. Check the upload diagnostics a day later: matched rows, errors, and the reasons.
The upload file
Column Example Notes
Google Click ID
Cj0KCQjw…
Exactly as captured. GCLIDs are case-sensitive; don't let a spreadsheet change them.
Email
jane@example.com
For enhanced conversions for leads. Lowercase and trimmed. Plain-text emails are only allowed for a one-time manual upload, where Google hashes them for you. Scheduled imports (Sheets, HTTPS, SFTP) need the email already hashed with SHA-256.
Conversion Name
SQL
Must exactly match the conversion action name in Google Ads.
Conversion Time
2026-10-14 15:30:00+0000
When the lead reached the stage, with time zone. Must be after the click.
Conversion Value
3000
Value of this stage (see below).
Conversion Currency
USD
ISO code.
Timing limits, from Google's offline conversion guidelines: a conversion with a GCLID can be imported up to 90 days after the click, but one matched only on email (enhanced conversions for leads) must be uploaded within 63 days of the click. Later rows are dropped. B2B deals that close after that can't be uploaded as "Closed won", which is one reason to bid on earlier stages such as SQL. Google recommends uploading at least daily, or on a regular fixed schedule if you can't. A weekly manual upload is fine to start, as long as it is the same day every week. As of October 2026
EU/UK: the upload template has Ad User Data and Ad Personalization consent columns. For leads from the EEA, UK or Switzerland, fill them from the consent the person gave on your site (your CMP's record), rather than leaving them blank.
What value to give each stage
Use expected value: average deal value × the share of leads at this stage that eventually close. Rough numbers are fine; update them each quarter.
Stage Illustrative close rate from stage Value if deals average $20,000
Demo request (website) 5% $1,000
Trial sign-up (website) 3% $600
Activated trial 10% $2,000
SQL 15% $3,000
Opportunity 25% $5,000
Closed won 100% Actual deal value
The close rates are illustrative. Take yours from your CRM. If you use regional pricing, use the deal value for the lead's region; this is how bidding learns that some regions are worth more (see Geographic targeting).
Turn a CRM export into a Google Ads upload file
Go deeper Why not just optimise for form fills forever?
Because cheap form fills and valuable leads come from different searches. A keyword like "free invoice template" can produce lots of form fills at a low CPA and almost no pipeline. A keyword like "invoice approval software for manufacturing" produces fewer, more expensive leads that become deals. On form fills alone, Smart Bidding will shift money towards the first. With SQL or pipeline values uploaded, it shifts towards the second. This is often the single biggest improvement in a B2B account.
Starter budget You may only have a handful of SQLs a month, which isn't enough to bid on. Upload them anyway as secondary conversions; they're your best quality report, and they build history. Keep bidding on the website conversion until volumes grow.
Advanced budget Automate uploads (scheduled from a Google Sheet or SFTP, or a native CRM connector) and add a daily or twice-weekly cadence, so bidding gets signals faster. With enough volume, move to value-based bidding (Target ROAS) on pipeline values.
Check yourself
Do this now
Consent banner live with Consent Mode v2 defaults (all four denied) loading before the Google tag. Confirm with legal what consent or notice your countries need, and set the CMP for any EU/UK visitors. Google tag (Google Ads + GA4) in the Astro base layout. One primary conversion action with a value, firing on the thank-you step. GA4 linked, auto-tagging on, Final URL suffix with UTMs set. GCLID and UTM hidden fields mapped to CRM fields; test lead verified. Enhanced conversions for leads turned on. Calendar reminder for month two: create offline conversion actions and do the first CSV upload.
Next: Geographic Targeting and Bidding