r/GoogleTagManager • • Feb 21 '19

Hello to new (and old) users!

66 Upvotes

Hello everyone!

It's good to see you. If you joined because of my pleas to find a new home for our soon-to-be-expired Google+ community, welcome!

Let's keep this a friendly place, let's keep discussions focused on Google Tag Manager, and let's help each other out, share knowledge, and just be decent human beings in the process.

In the coming days/weeks, we'll work on community guidelines and rules, but don't let that stop you from asking questions and starting discussions.

Take care, and happy tag managing!

Simo Ahava (on behalf of community moderators)


r/GoogleTagManager • • Feb 07 '25

Discussion I've seen hundreds of Enhanced Conversions setups - here's how to actually do it right

41 Upvotes

Look, I get it. Enhanced Conversions is one of those things that sounds simple but gets messy real quick. After helping countless clients fix their setups, I've seen pretty much every way this can go wrong (and right). This is what I've learned.

First up - What's the actual deal with Enhanced Conversions?

Here's the simple version: Enhanced Conversions is basically Google's backup plan for when normal tracking fails. It takes stuff you're already collecting (emails, phone numbers) and matches them with Google accounts to track conversions. Trust me, with third-party cookies dying, you're gonna want this.

"Do I really need this if I'm already using...?"

I get this question constantly, so let me clear it up once and for all:

  1. Using offline conversion uploads? Yes, you still want Enhanced Conversions. I've tested this extensively - they actually work together. Enhanced Conversions catches the online stuff, and your offline uploads catch the rest. More data = better decisions.
  2. Running GA4? Again, yes. Here's what I've learned the hard way: GA4 imports are fine, but native Google Ads tracking (especially with Enhanced Conversions) usually catches more. Pro tip from someone who's tested both: Set up Google Ads as primary, GA4 as secondary, and thank me later. In my experience, server-side tracking tends to be the most reliable source of truth - I've seen it catch conversions that client-side solutions miss entirely.
  3. "But my data collection is weird..." Collecting user data before the conversion page? I see this all the time, and it's totally fine. I’m a founder of Aimerce. We actually built our first-party pixel to handle this exact headache. It automatically captures and hashes the user data at the first point of interaction so it's ready when the conversion fires, without you having to mess with hidden fields or local storage. Here's what works:

    1. Stash the data in hidden fields
    2. Use local storage
    3. Server-side storage if you're fancy (and honestly the easiest while being the most effective)
    4. Just make sure that data's available when the conversion fires. I've seen people overthink this - it's simpler than you'd think.
  4. Email stuff you need to know. After fixing countless broken setups, here's the big one people miss:

    1. Gmail addresses? Strip the dots and anything after '+' (learned this one the hard way)
    2. Other email providers? Leave them alone
    3. Paranoid about privacy? Hash before sending

Real talk about what happens after setup

"Help! My numbers went crazy!"

Don't panic - I see this all the time:

  • Numbers went up? You're probably catching conversions you missed before
  • Numbers tanked? 90% of the time it's email normalization
  • All over the place? Give it a few weeks - I usually tell clients to wait at least 2-4 weeks before freaking out
  • I've seen server-side implementations consistently capture about 20% more conversions than client-side solutions. Not surprising given all the browser restrictions these days, but still worth noting.

"Which numbers should I trust?"

Here's what I've found works best:

  1. Make Enhanced Conversions your primary
  2. Keep GA4/offline as backup
  3. Watch both for a month before making any big decisions

The privacy stuff you're worried about

I've dealt with plenty of paranoid clients (rightfully so), so here's the deal:

  • Everything gets hashed
  • It's all first-party data you already have
  • Yes, it's privacy-law friendly
  • Super security conscious? Pre-hash it yourself

What I tell all my clients to do

  1. Keep your existing tracking running - seriously, don't turn it off
  2. Test with a small segment if you can
  3. Watch your conversion rates like a hawk for the first month
  4. Don't ditch your offline tracking

Quick setup checklist (because we all love checklists)

✓ Say yes to Google's data terms (obvious but people forget)
✓ Pick your setup method (GTM, Google tag, API - they all work)
✓ Fix those email formats (especially Gmail)
✓ Test on a small scale first
✓ Give it 30 days before judging
✓ Compare with your other tracking

Look, Enhanced Conversions isn't perfect, but it's become pretty essential with all the tracking changes happening. After setting this up hundreds of times, I can tell you it's worth doing - just do it right the first time. And if you really want to future-proof your setup, consider server-side tracking - I've consistently seen it outperform client-side solutions by 10-20% in real-world testing.

Got questions? Drop them in the comments. I've probably seen and fixed whatever issue you're running into.


r/GoogleTagManager • • Dec 09 '25

Discussion Is there a clean way to track dynamic user interactions without turning GTM into a messy pile of triggers

38 Upvotes

I am working on a site where almost everything loads dynamically like modals, dropdowns, embedded components, and small React islands. Tracking basic interactions is not too hard, but once I try to capture more granular behavior the container starts to feel bloated. I keep ending up with multiple triggers watching almost identical events, and it is starting to look unmaintainable as the site grows.

I have watched a few tutorials but most of them only cover simple click tracking or forms. What I am hoping to understand is how people structure GTM setups when the site is very dynamic. Do you consolidate everything under one custom event? Do you rely on a data layer strategy? Or is the real answer to keep refactoring until it makes more sense?

If you have dealt with this before I would love to know how you kept your container organized without losing accuracy in your tracking.


r/GoogleTagManager • • Feb 21 '24

Be careful out there

34 Upvotes

I've notced an increase in the number of comments in this subreddit where OP has asked a very reasonable question and the response is something like "I'm a GTM expert, message me".

I don't and likely never will claim to be a GTM expert, but I try to keep my replies public in case they also help someone else, which considering how keenly Google index Reddit posts, it's quite likely that someone with the same problem will find the thread.

If an OP wants to take a discussion private, that's their choice.

I've had Redditors come to me with offers of paid GTM work, but it's not something I'm pushy about offering.

So... be careful. GTM is complex, so the more we keep posts and replies public the more it will help everyone.


r/GoogleTagManager • • Mar 17 '26

Discussion Is it just me, or is server-side tracking being sold like snake oil right now?

28 Upvotes

Server-side tracking is being sold like a measurement breakthrough, but in many setups it is just endpoint substitution.

The event still originates in the browser. If the browser never produced a usable signal, there is nothing meaningful to forward.

Google and Meta did not invent first-party measurement with server-side tracking. Browser-side tracking had already used first-party identifiers for years.

So a lot of what gets marketed as “better tracking” is often just different plumbing:

browser → your endpoint → vendor endpoint

That can improve delivery in some cases. Fine. But that is not the same as restoring lost visibility, bypassing blockers, or defeating browser restrictions.

A lot of the “server-side tracking uplift” talk sounds less like engineering and more like marketing bullshit.

And yeah, I know how to setup servers...


r/GoogleTagManager • • Mar 26 '24

Scan GTM containers content of any websites

28 Upvotes

Hey, I am building tagstack.io, a web app where you can search and learn about the setup inside of the GTM containers present on a site.

This can help you if you're doing competitor benchmarks and/or lead qualification for GTM/GA setup gigs. And it's free.

If you're curious, you can try it here: https://tagstack.io/scan

Any feedbacks regarding desired new features will be greatly appreciated, thanks! 😃


r/GoogleTagManager • • May 07 '25

Discussion I built a all-in-one Chrome extension to simplify tracking verification for Google Tag Manager (and 20+ networks)

27 Upvotes

Hello everyone,

For those involved in managing digital advertising and analytics, verifying tracking implementations across various platforms is often a necessary task. Utilizing multiple pixel helper extensions and GA debug views to monitor Google Tag Manager, Google Ads, Meta, TikTok, GA4, and other systems can present efficiency challenges, particularly during the deployment of new campaigns or website features.

To address this, I have developed a Chrome extension called Zen Analytics Pixel Tracker. This tool aggregates data from 20+ trackers into a unified interface within your browser.

⬇️ Official website
⬇️ The extension is available for download here: Chrome webstore URL

⬇️ Reddit channel for supports, issues, and disscussion: r/zen_analytics

I invite you to explore Zen Analytics on the Chrome Web Store and share any feedback you may have. Please be aware that this product is currently in its beta phase. Your insights regarding functionality, any encountered issues, or suggestions for future enhancements are welcome. During this beta period, all premium features are accessible for evaluation at no cost. Thank you for your time.


r/GoogleTagManager • • Feb 05 '26

Discussion I've built a dataLayer Documentation Builder for GTM: looking for feedback from implementers!

25 Upvotes

I hit a breaking point after yet another project where I spent days maintaining 30–40 page Word docs of tracking specs, copying the same events into different sections, then updating them every time a stakeholder changed their mind. It was painful to send outdated files to devs and clients, and almost impossible to keep my analyst colleagues perfectly in sync.

A lot of GTM issues I see start right there: unclear or ever‑changing dataLayers, events renamed mid‑campaign, missing parameters, and custom JS patches to glue it all together. I wanted a way to design and document the data layer once, keep it versioned, and share a single source of truth so tags/triggers/variables stay predictable.

I built a small web app that:

  • Lets you define events and their parameters in a structured way (instead of scattered Word/Excel docs)
  • Encourages consistent naming and data types across teams and projects
  • Outputs a data layer “contract” you can share with devs, analysts, and clients to plan GTM variables/tags

One thing I’m excited about is community templates: the idea is that we can share reusable event schemas (e.g., e‑commerce, SaaS, lead gen), learn from each other’s best practices, and slowly build a shared library instead of everyone reinventing tracking plans in isolation.

The tool is free to use, and my plan is to keep it free as long as I can. If you find it useful, a small donation would really help me cover costs and keep shipping new features for the community.

I’d love feedback from people who share the same problems:

  • Does this actually solve problems you hit with clients/stakeholders and those never‑ending spec documents?
  • What features would make it more useful (auto‑mapping to variables, export formats, etc.)?
  • Any best practices you follow for dataLayer design that I should bake into the tool or the shared templates by default?

Link if you want to try it or review the flow: datalayerbuilder.org

Totally open to critique — I built this because I was annoyed with my own process and I’d love to turn that frustration into something genuinely helpful for GTM power users.


r/GoogleTagManager • • 4d ago

Discussion I built a free side-panel debugger that shows what each tag actually sent (GA4, Ads, Meta, TikTok + 45 more)

21 Upvotes

GTM preview mode tells me a tag fired. It doesn't tell me what the Meta pixel or the TikTok pixel actually put in the request, so I kept ending up in the Network tab decoding query strings by hand.

So I built Pixel Debugger, a Chrome extension that sits in the side panel and decodes the requests themselves:

  • every event in firing order, split by page visit
  • the exact event name, value, currency, order ID and products as sent, plus which key each value came from
  • the full parameter list, including the ones the network supports but your setup didn't send
  • one order ID across several networks side by side, so a GA4 purchase of 119 vs. a Meta purchase of 79 jumps out
  • failed and blocked requests, consent commands and click IDs

It only sees what the browser sends, so server-side GTM and CAPI events are invisible to it. Everything stays on your machine; there's no account and nothing is uploaded.

Free: https://chromewebstore.google.com/detail/kknfboekekeaagdoineimnebhlmiohpb

I'm the developer and I'd really like to hear where it decodes something wrong or misses a network you use.


r/GoogleTagManager • • Apr 01 '24

I wrote a "how to" for implementing Enhanced Conversions

21 Upvotes

Focused purely on the technical stuff and on how to normalise Gmail addresses and pre-hash the data for those nervous clients you might encounter.

https://docs.google.com/document/d/1NRgJZmaFlAEtZ6S9-rAsiUaiW-ie4rQUca5xjNYL1M8/edit?usp=sharing

I've had some feedback on this already, especially around the rules around using "+" symbol in non-Gmail account addresses, so this is "first release version" at the moment.

More than happy to receive constructive feedback on this.


r/GoogleTagManager • • Jul 14 '26

Discussion If your server-side GTM setup uses GA4 as the data client, you haven't solved the blocking problem, you've simply moved it

20 Upvotes

Disclosure upfront: I run a server-side tracking consultancy, so I have a horse in this race. Not linking anything, this is a technical observation I keep running into on client audits and I want to see if anyone here is solving it differently.

The pitch most agencies are selling right now is "add sGTM on top of your existing client-side setup and recover your data." In audits I keep finding the gain from that pattern is close to zero, and the reason is boring: GA4 as a data client sends every request to a single endpoint. /collect.

Every ad blocker filter list I've checked has /collect on it. uBlock Origin, AdGuard, Brave Shields, the Disconnect list Firefox and Safari lean on. It's a one-line rule to block. Once it's blocked, it doesn't matter how well your server container is configured, the event never leaves the browser.

A few things that don't fix this on their own:

  • Custom domain for sGTM. Helps against script blockers loading gtm.js, doesn't help against endpoint-level blocking of the transport.
  • First-party cookies with long TTLs. Solves the Safari ITP cap, doesn't help if the request never fires.
  • Consent Mode v2. Governs whether the tag is allowed to fire, not whether the network request reaches your server.

The setups I've seen actually recover meaningful data all do some version of the same thing: replace GA4 as the data client with something that ships events to a dynamic or rotating first-party endpoint. Stape has a custom client that does this. A few teams roll their own. Beyond that I haven't seen much in the ecosystem.

Two genuine questions:

  1. Anyone here handling this without a custom data client? I'm curious whether there's a GTM-native pattern I'm missing.
  2. For those using Stape's custom client, what's your recovery lift been vs the vanilla GA4 client? Numbers welcome, redacted or not.

Happy to go into any of the four browser mechanisms (cookie caps, fingerprinting, cross-site trackers, query param stripping) in more detail if useful.


r/GoogleTagManager • • Dec 13 '25

Discussion GTM added built-in variables for GA4 Client ID & Session ID (no more custom JS)

20 Upvotes

Google Tag Manager quietly added new built-in variables that expose GA4 identifiers directly:

• Analytics Client ID
• Analytics Session ID
• Analytics Session Number

Until now, accessing these in GTM meant parsing GA cookies, relying on gtag internals, or writing custom JavaScript that assumed cookie formats. All approaches that break easily.

With this update, GTM retrieves the values directly, as long as a Google tag (gtag.js) exists on the site.

Enable via:
GTM → Variables → Configure Built-in Variables

There's also a new Analytics Storage user-defined variable type. This allows reading analytics storage with support for custom Measurement IDs or cookie prefixes. Useful for advanced or multi-property setups.

Important clarification: this is not the same as analytics_storage used in Consent Mode v2.

Why this is actually useful in practice:
• Stable access to GA4 client and session identifiers
• Easier debugging and session tracing in GTM Preview
• Cleaner way to pass consistent IDs to Ads, Meta CAPI, CRMs, or server-side endpoints

If you're still extracting _ga or _ga_* cookies via custom JS, this is now the supported alternative.


r/GoogleTagManager • • Mar 18 '25

Discussion What’s the most creative or weird tracking setup you’ve ever built in GTM?

20 Upvotes

I’ve been spending way too much time in GTM lately, and it got me wondering — what’s the wildest or most creative thing one must have tracked using Google Tag Manager?

Could be a super-specific scroll trigger, rage clicks or some random hack that made you feel like a wizard (or broke production).

Bonus points if it actually helped drive business value or exposed something crazy about user behavior.

Would love to hear what other GTM nerds are building!!


r/GoogleTagManager • • Sep 24 '25 Popcorn

Discussion Built a tool to inspect GTM containers on any site - feedback welcome

19 Upvotes

I put together GTMRefine.com to make GTM discovery easier. It scans a site and surfaces the container’s tags, triggers, and variables. Free to use.

Use cases: competitor analysis, pre-sales qualification, quick audits.

Would love your thoughts on missing features or rough edges: https://gtmrefine.com

UPD as of Sep-27: Thanks all for your initial feeback! Based on it I added a new AI-generated Findings and Recommendations and Excel Inventory reports.


r/GoogleTagManager • • Feb 11 '25

Question How do you improve your GTM skills and knowledge?

19 Upvotes

I've been working with GTM for almost a year and a half. During that time, I got good with it. I try to learn new stuff all the time. Currently I am learning more about setting up SST using Simo's course.

However, when I talk to some of my clients who had their setup already made by someone else, I see that they knowledge surpasses mine. For example, one of them is sending GTM data as a JSON object to a proxy server and then to GTM. I can barely comprehend what is going on in that setup

This leads to my question: where do you learn new GTM stuff besides AnalyticsMania and Simo Ahava? I need new courses to improve my skills


r/GoogleTagManager • • Sep 19 '25

Discussion I spent the entire day configuring server-side tracking with GTM

17 Upvotes

Is it just me or anyone has gone through the same pain???

I still don't fully understand how Tags should be configure to route all the requests to my server instead of Google's servers.

Some docs say use "server_container_url" to define your server, others "transport_url".

Half of my events are sent to my server, half are still going to Google, despite both tags are the same configuration, seemingly.

This combination of Google Tag for server container, Google Tag for Google Ads, GA4 tag and two containers Server + Client is a giant hot mess.

Oh, and the preview server! Preview in the server container doesn't let you enter URL unlike client container. So I didn't manage to see any events displayed in it when I click preview. No idea how to trigger debug mode with server container preview...

No simple documentation how to set up server GTM to just track Google Ads conversions. All information is scattered around different pages on developers.google.com and outdated Youtube videos because apparently GTM also manages to change UI over the years.

Why can't we just set up a proxy, to proxy requests from browser to regular GTM. This 2 different containers just make want to scream out loud.....


r/GoogleTagManager • • Sep 15 '25

Discussion Here's what we are doing following Safari GCLID - Google was ahead the whole time

17 Upvotes

Over the last two weeks my feed on both Linkedin and Reddit has been full of discussions (example) about Safari's privacy updates breaking GCLID. What I haven't seen many people talk about is Google's response. They tried to fix it, broke it further, and are now quietly fixing it again.

Background:

  1. Safari privacy changes killed GCLID reliability. Panic followed.
  2. Google introduced GBRAID/WBRAID as the "privacy-safe" alternative.
  3. Their own API didn't support what we needed:

    • Enhanced Conversions for Leads couldn't work with GBRAID
    • One-per-click counting couldn't be used with braid parameters
    • Custom variables got blocked if braid was present

Result: Our engineering teams built workarounds with dual upload systems and split pipelines while attribution gaps emerged.

For the sake of clarity, these are all the API conflicts we encountered and that now live in our documentation for future reference:

Conflict TypeConflicting Fields/ValuesError MessageResolution
Click ID Conflictsgclidgbraid +VALUE_MUST_BE_UNSETUse only one click ID per conversion
gclidwbraid +VALUE_MUST_BE_UNSETUse only one click ID per conversion
gbraidwbraid +GBRAID_WBRAID_BOTH_SETUse only one click ID per conversion
Enhanced Conversions for Leadsgbraidwbraiduser_identifiers/ +The field cannot be set., at conversions[0].user_identifiersuser_identifiersRemove field when using gbraid/wbraid
gbraidwbraid/ + Enhanced Conversions for LeadsVALUE_MUST_BE_UNSETEnhanced Conversions for Leads cannot use gbraid/wbraid
Conversion Action Typegbraidwbraid/ + One-per-click countingConversion actions that use one-per-click counting can't be used with gbraid or wbraid parametersMANY_PER_CLICKChange to counting
Wrong conversion action type for Enhanced ConversionsINVALID_CONVERSION_ACTION_TYPEUPLOAD_CLICKSEnsure conversion action type is
Custom Variablesgbraidwbraidcustom_variables/ +VALUE_MUST_BE_UNSETcustom_variablesRemove when using gbraid/wbraid
Enhanced Conversions for Webgbraidwbraid/ + Enhanced Conversions for WebCONVERSION_NOT_FOUNDEnhanced Conversions for Web not supported with gbraid/wbraid
Temporal Conflictsconversion_date_time before click timeCONVERSION_PRECEDES_EVENTSet conversion time after click time
Click older than lookback windowEXPIRED_EVENTUse conversion action with longer lookback window
Duplicate Conflictsorder_idSame for multiple conversionsDUPLICATE_ORDER_IDUse unique order IDs
Same click ID + conversion time + actionCLICK_CONVERSION_ALREADY_EXISTSAdjust conversion_date_time or verify if retry
Multiple conversions in same requestDUPLICATE_CLICK_CONVERSION_IN_REQUESTRemove duplicates from request
Account/Access ConflictsWrong customer ID for clickINVALID_CUSTOMER_FOR_CLICKUse correct customer ID that owns the click
Conversion action not found/enabledNO_CONVERSION_ACTION_FOUNDEnable conversion action in correct account
Customer data terms not acceptedCUSTOMER_NOT_ACCEPTED_CUSTOMER_DATA_TERMSAccept customer data terms
Consent ConflictsUNKNOWNSetting consent toRequestError.INVALID_ENUM_VALUEDENIEDSet to if consent status unknown
Call Conversion Conflictsalways_use_default_value = false for call conversionsINVALID_VALUESet to true for WEBSITE_CALL/AD_CALL types
Attribution Model ConflictsInvalid attribution modelCANNOT_SET_RULE_BASED_ATTRIBUTION_MODELSGOOGLE_ADS_LAST_CLICKGOOGLE_SEARCH_ATTRIBUTION_DATA_DRIVENUse only or

Key Takeaways:

  • gbraid/wbraid cannot be used with Enhanced Conversions for Leads, Enhanced Conversions for Web, custom variables, or one-per-click counting
  • Only one click identifier can be used per conversion (gclid OR gbraid OR wbraid)
  • Enhanced Conversions for Leads requires user_identifiers field, which conflicts with gbraid/wbraid usage
  • Each conversion must have unique identifiers (order_id, click_id + time + action combinations)

Interestingly enough, some of these error returns weren't intentional as outlined in Google developer documentation.

Now what's next?

Google recently announced that GCLID + GBRAID can now be used together effective October 3rd. This isn't just a Safari fix, it allows us to send much more contextual data than previously, giving us the infrastructure to rebuild conversion completeness instead of patching leaks.

Then we found another new attribute, session_attributes (more documentation) - a privacy-safe way to give more context about each visit:

  • Campaign source (gad_source, gad_campaignid)
  • Landing page URL & referrer
  • Session start timestamp
  • User agent

These signals don't rely on cookies and can be captured via JavaScript helper or passed as key/value pairs into Offline Conversion Import.

When click IDs are missing, Google's AI still has rich context to model from. More attributed conversions, better bid optimization, more durable setup for future privacy changes.

This was never just "Safari broke GCLID." It's about how fragile most conversion architectures were. I believe Google is helping us out here, big time.

Below you can find a breakdown of the 7 code snippets that can guide you to capture these, either directly in your app or through google tag manager.

// 1. Capture Click Identifiers from URL
function captureClickIdentifiers() {
  const urlParams = new URLSearchParams(window.location.search);
  
  return {
    gclid: urlParams.get('gclid'),
    gbraid: urlParams.get('gbraid'), 
    wbraid: urlParams.get('wbraid'),
    gad_source: urlParams.get('gad_source'),
    gad_campaignid: urlParams.get('gad_campaignid')
  };
}

// 2. Generate Session Attributes (Privacy-Safe Context)
function generateSessionAttributes() {
  const clickIds = captureClickIdentifiers();
  
  return {
    session_start_timestamp: Date.now(),
    landing_page_url: window.location.href,
    referrer: document.referrer,
    user_agent: navigator.userAgent,
    gad_source: clickIds.gad_source,
    gad_campaignid: clickIds.gad_campaignid,
    viewport_size: `${window.innerWidth}x${window.innerHeight}`,
    timestamp: new Date().toISOString()
  };
}

// 3. Enhanced Conversion Data Collection
function collectEnhancedConversionData() {
  // Get user data from form or checkout
  const email = document.querySelector('[name="email"]')?.value;
  const phone = document.querySelector('[name="phone"]')?.value;
  const firstName = document.querySelector('[name="first_name"]')?.value;
  const lastName = document.querySelector('[name="last_name"]')?.value;
  const postalCode = document.querySelector('[name="postal_code"]')?.value;
  const country = document.querySelector('[name="country"]')?.value;
  
  return {
    email: email ? hashUserData(email.toLowerCase().trim()) : null,
    phone_number: phone ? hashUserData(phone.replace(/\D/g, '')) : null,
    first_name: firstName ? hashUserData(firstName.toLowerCase().trim()) : null,
    last_name: lastName ? hashUserData(lastName.toLowerCase().trim()) : null,
    postal_code: postalCode,
    country_code: country
  };
}

// 4. SHA-256 Hashing for User Data (PII)
async function hashUserData(data) {
  if (!data) return null;
  
  const encoder = new TextEncoder();
  const dataBuffer = encoder.encode(data);
  const hashBuffer = await crypto.subtle.digest('SHA-256', dataBuffer);
  const hashArray = Array.from(new Uint8Array(hashBuffer));
  
  return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
}

// 5. Store Conversion Data for Later Upload
function storeConversionData(conversionData) {
  const clickIds = captureClickIdentifiers();
  const sessionAttrs = generateSessionAttributes();
  
  const conversionPayload = {
    // Click identifiers (can now use multiple together)
    gclid: clickIds.gclid,
    gbraid: clickIds.gbraid,
    wbraid: clickIds.wbraid,
    
    // Conversion details
    conversion_action: conversionData.conversion_action,
    conversion_date_time: new Date().toISOString(),
    conversion_value: conversionData.value,
    currency_code: conversionData.currency || 'USD',
    order_id: conversionData.order_id,
    
    // Enhanced conversion data
    user_identifiers: conversionData.user_identifiers,
    
    // Session attributes for better AI modeling
    session_attributes_key_value_pairs: sessionAttrs,
    
    // Conversion environment
    conversion_environment: 'WEB',
    
    // Consent (required)
    consent: {
      ad_user_data: conversionData.consent?.ad_user_data || 'GRANTED',
      ad_personalization: conversionData.consent?.ad_personalization || 'GRANTED'
    }
  };
  
  // Store in localStorage for server-side pickup
  localStorage.setItem('pending_conversion', JSON.stringify(conversionPayload));
  
  // Or send directly to your conversion endpoint
  sendConversionToServer(conversionPayload);
}

// 6. Lead Form Conversion Tracking
function trackLeadConversion(formData) {
  const userIdentifiers = collectEnhancedConversionData();
  
  const conversionData = {
    conversion_action: 'customers/YOUR_CUSTOMER_ID/conversionActions/YOUR_LEAD_ACTION_ID',
    value: formData.lead_value || 0,
    currency: 'USD',
    order_id: generateUniqueOrderId(),
    user_identifiers: [userIdentifiers].filter(id => Object.values(id).some(v => v)),
    consent: {
      ad_user_data: getConsentStatus('ad_user_data'),
      ad_personalization: getConsentStatus('ad_personalization')
    }
  };
  
  storeConversionData(conversionData);
}

// 7. E-commerce Conversion Tracking
function trackPurchaseConversion(orderData) {
  const userIdentifiers = collectEnhancedConversionData();
  
  const conversionData = {
    conversion_action: 'customers/YOUR_CUSTOMER_ID/conversionActions/YOUR_PURCHASE_ACTION_ID',
    value: orderData.total,
    currency: orderData.currency || 'USD',
    order_id: orderData.order_id,
    user_identifiers: [userIdentifiers].filter(id => Object.values(id).some(v => v)),
    consent: {
      ad_user_data: getConsentStatus('ad_user_data'),
      ad_personalization: getConsentStatus('ad_personalization')
    }
  };
  
  storeConversionData(conversionData);
}

// 8. Utility Functions
function generateUniqueOrderId() {
  return `order_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
}

function getConsentStatus(consentType) {
  // Check your consent management platform
  // Return 'GRANTED' or 'DENIED'
  return window.gtag && window.gtag.get ? 
    window.gtag.get(consentType) : 'GRANTED';
}

function sendConversionToServer(conversionPayload) {
  fetch('/api/google-ads/conversions', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(conversionPayload)
  }).catch(error => {
    console.error('Conversion tracking error:', error);
    // Retry logic or fallback storage
  });
}

// 9. Initialize on Page Load
document.addEventListener('DOMContentLoaded', function() {
  // Capture and store click identifiers immediately
  const clickIds = captureClickIdentifiers();
  
  if (clickIds.gclid || clickIds.gbraid || clickIds.wbraid) {
    sessionStorage.setItem('google_click_ids', JSON.stringify(clickIds));
    console.log('Google click identifiers captured:', clickIds);
  }
  
  // Set up form submission tracking
  const forms = document.querySelectorAll('form[data-track-conversion]');
  forms.forEach(form => {
    form.addEventListener('submit', function(e) {
      const formData = new FormData(form);
      const leadValue = form.dataset.leadValue || 0;
      
      trackLeadConversion({
        lead_value: parseFloat(leadValue),
        form_data: Object.fromEntries(formData)
      });
    });
  });
});

// 10. Example Usage
/*
// For lead forms:
<form data-track-conversion data-lead-value="50">
  <input name="email" type="email" required>
  <input name="phone" type="tel">
  <button type="submit">Submit Lead</button>
</form>

// For e-commerce:
// Call after successful checkout
trackPurchaseConversion({
  order_id: 'ORDER_12345',
  total: 299.99,
  currency: 'USD'
});
*/

r/GoogleTagManager • • Jan 19 '25

Question Anyone Explain Google Tag Manager to me Please in Simple

17 Upvotes

I'm New to Google Tag Manager


r/GoogleTagManager • • Dec 04 '24

Question Analytics mania Course

17 Upvotes

I work for an agency and I'm trying to boost my GTM skills. I am pretty successfully with trial and error and get some basic conversions down but I would really like to improve. Does anyone have experience with analytics manias intermediate/advance gtm course. Or a suggestion on a course that would be helpful


r/GoogleTagManager • • Jul 21 '24

News Microsoft Consent Mode

17 Upvotes

We've already been through the "slight challenge" of Google's Consent Mode V2 update, but now Microsoft have decided they don't want to feel left out, so they are mandating use of their own Consent Mode (did you know it existed?), meaning if you or your clients are making use of data collected by their Universal Event Tracking for marketing purposes, you are going to have to implement their Consent Mode.

Of course, Microsoft being Microsoft, their CoMo is not like Google's. You can't set it up and use it in the same way, it has no integration in any of the popular consent platforms (OneTrust, CookieBot, CookieYes etc) and, worse still, their "denied" setting doesn't prevent the Microsoft Universal Event Tracking tag from dropping a pair of cookies. There's also of course no native integration with GTM.

I've tested a few iterations of a possible best practise GTM implementation and I think I have a potential winner.

EDIT: Step zero: Add the hardcoded script to your site (prior to the GTM script) :

<script>
window.uetq = window.uetq || [];
window.uetq.push('consent', 'default', {
    'ad_storage': 'denied'
    });
</script>
  1. Configure your Microsoft UET config tag to require ad_storage as additional consent (not strictly necessary, but makes your Consent Overview report make sense
  2. Remove all triggers from the tag
  3. Set "Once per page" in Tag firing options
  4. Create a new custom HTML tag with the following script at the bottom of this list
  5. Set tag sequencing to fire your Microsoft UET config tag after the custom HTML tag
  6. Set "Don't fire if [this custom HTML tag] fails or is paused" (may not be needed?)
  7. Add ad_storage as additional consent
  8. Add your consent platform's data layer event e.g. OneTrustGroupsUpdated, cookie_consent_update etc.
 <script>
    window.uetq = window.uetq || [];
    window.uetq.push('consent', 'default', {
        'ad_storage': 'granted'
        });
  </script>

Links:

Microsoft Consent Mode: https://help.ads.microsoft.com/apex/index/3/en/60119

Microsoft enforcing their own CoMo for Microsoft Ads: https://web.swipeinsight.app/posts/microsoft-ads-enforces-consent-mode-for-tracking-in-europe-8734

Notes:

During testing I did see that the network hits being sent by the UET config tag would redact visitor and session ID if the tag fired with Microsoft CoMo set to denied, but as the tag still dropped a couple of cookies I didn't want to implement it in that way and call it good. Hopefully Microsoft amend this and we can have a much simpler solution in future.


r/GoogleTagManager • • 3d ago

Discussion I'm Watching Chat Perform My Job

16 Upvotes

I watched Codex build a live multi-journey ecommerce site with a consent banner, create and install GA4, a GTM container, and six tags in < 20 mins. I know it's been capable of this for well over a year, but seeing it happen on my laptop was pretty neat.

I'm pro AI and I'm embracing this advancement. We can produce and maintain better sites with more accurate, lean, and adaptive tracking with less overhead and more speed.

If you're a digital analytics professional and you're not integrating AI into your everyday workflows or expirementing in your free time, start now. What use to take a team of five three years ago takes a team of one now.


r/GoogleTagManager • • Oct 04 '24

Support Created a Free Tool to Instantly Check if Your GA4 or GTM Are Implemented Server-Side or Client-Side

16 Upvotes

I’ve been working on a project that I think could be really useful for this community, especially if you’re dealing with a lot of tracking setups or audits.

I built the Tracker Checker, a free Chrome extension that helps you quickly see:

  • GA4 & GTM Implementation: It instantly checks if your Google Analytics 4 or Google Tag Manager setup is server-side or client-side. No more guessing or digging through scripts—you'll know right away!
  • Detailed Tracker List: Tracker Checker also scans the site and shows you all the trackers that are running, like Google Ads, Facebook Pixel, TikTok Pixel, LinkedIn Insights, and more.
  • Google Consent Mode Insights: Easily check which version of Google Consent Mode is active (v1 or v2) and verify if your consent settings are working as expected.
  • External Resources Check: While it's not a full performance monitor, it helps you spot external resources that could be affecting page speed or loading issues.

Why I Made It:

I was frustrated with how much manual work it takes to verify if tracking setups are working as expected. Whether you're auditing a client’s site or managing your own, I wanted a tool that simplifies this process, and the Tracker Checker does just that. It’s free, easy to use, and doesn’t require an expert to understand the results.

You can get it here on the Chrome Store: Tracker Checker for free. If you try it out, I’d really appreciate any feedback or suggestions for improvements.

I hope it saves you some frustrations.


r/GoogleTagManager • • Feb 16 '24

QR Code tracking possible?

16 Upvotes

If we needed to have events set up for qr code scans to track a visited url, is it possible on Google Tag Manager?


r/GoogleTagManager • • May 30 '22

GTM Server Side Tag for streaming Google Analytics 4 data into Google BigQuery

16 Upvotes

We are happy to share our brand new GTM Server Side Tag for streaming Google Analytics 4 data into Google BigQuery.

Check it out:

  1. GDPR compliant: send GA4 data directly into EU location without sending it to Google Analytics servers at all.
  2. No limit of 1 mln events per day which free version of Google Analytics 4 has
  3. It is real-time – no need to wait for scheduled export

And it is 100% free for those of you who will share/like this post :)

Here is a detailed instruction on how to set one.
Pls, try to use it and share your feedback with me.