๐Ÿ”— Google Ads Click IDs

Understanding gclid, wbraid, and gbraid

This guide explains the Google Ads identifiers (gclid, wbraid, gbraid) and how they fit into your GTM + GA4 setup.

Quick Summary

Think of gclid, wbraid, and gbraid as tags attached to the user when they arrive from an ad. Your job is to keep them, not delete them, and optionally store them for later use.

1. What are gclid, wbraid, gbraid?

gclid โ€“ Google Click Identifier

  • Used when: A user clicks a Google Ads ad (Search, Display, etc.) with auto-tagging ON.
  • Where you see it: As a URL parameter on your landing page:
    • https://gtm-learning.test/?gclid=EAIaIQobChMI...
  • Purpose:
    • Lets Google Ads and GA4 know which exact ad/campaign/keyword generated a visit or conversion.
    • Enables conversion tracking and attribution back to the correct campaign.

wbraid / gbraid โ€“ Web & Google Click IDs for Privacy / iOS

wbraid:

  • Used mainly for web-to-app measurement and some privacy / cookie-restricted contexts.
  • Helps attribute conversions when traditional cookies or gclid can't be used reliably.

gbraid:

  • Used mainly for iOS and app campaigns, also related to privacy-preserving attribution.
  • Similar role: helps Google understand which ad led to a conversion without relying fully on cookies.

2. Where do these parameters appear?

Example landing URLs when a user clicks an ad:

  • Search ad with auto-tagging:
    • https://gtm-learning.test/?gclid=EAIaIQobChMI123...
  • Web-to-app / privacy scenario:
    • https://gtm-learning.test/?wbraid=CjkKCQjw...
  • iOS / app-related:
    • https://gtm-learning.test/?gbraid=0AAAA...

Important:

  • They are query parameters only.
  • You usually do not set them manually; Google adds them to ad URLs.

3. Best Practices for Your Site

โœ… 3.1. Never strip these parameters

Bad practice: Cleaning URLs on load and removing ?gclid=... / ?wbraid=... / ?gbraid=...

Good practice: Let them stay at least for the first page load, so GTM/GA4/Ads can read them.

If you really want a "clean URL", do this after you've stored them (see section 3.3).

โœ… 3.2. Make them available to GTM

In GTM, create URL variables:

  1. Go to Variables โ†’ New โ†’ URL.
  2. Variable Type: URL.
  3. Component Type: Query.
  4. Query Key:
    • gclid
    • wbraid
    • gbraid
  5. Give them names, e.g.:
    • url_gclid
    • url_wbraid
    • url_gbraid

You can then send these values as GA4 event parameters or to other tags (e.g., server-side endpoint).

โœ… 3.3. Optionally store them in localStorage / cookie

This helps when:

  • The user arrives with ?gclid=... on one page,
  • But converts later on another page without the parameter.

Simple client-side approach:

// Example utility you can include in your page
(function storeClickIds() {
  if (!window.URLSearchParams) return;

  const params = new URLSearchParams(window.location.search);
  const clickIds = ['gclid', 'wbraid', 'gbraid'];

  clickIds.forEach(function (key) {
    const value = params.get(key);
    if (value) {
      // Store in localStorage (for learning/demo)
      localStorage.setItem(key, value);
      // In production you might also set a cookie for your backend
      // document.cookie = key + '=' + encodeURIComponent(value) + ';path=/;max-age=' + 90*24*60*60;
      console.log('Stored', key, value);
    }
  });
})();

For real projects: Storing in a first-party cookie and passing to your backend or server-side GTM container is common.

โœ… 3.4. Use them in your conversion events

When you send a conversion (e.g., purchase event) to:

  • GA4 via GTM,
  • Google Ads via a conversion tag or via GA4 imports,

you can attach these IDs as event parameters.

Example GA4 Event tag in GTM:

  • Event Name: purchase
  • Event Parameters:
    • gclid โ†’ {{url_gclid}} (or a cookie variable)
    • wbraid โ†’ {{url_wbraid}}
    • gbraid โ†’ {{url_gbraid}}

Google Ads / GA4 will then use them for attribution.

4. Privacy & Consent (High-level)

Because these IDs relate to advertising and user tracking:

  • In regions with strict privacy laws (e.g., GDPR, ePrivacy, CPRA):
    • You should only set cookies / store IDs / fire ad tags after consent.
    • Typically handled using a Consent Management Platform (CMP).
    • GTM has Consent Mode to control how tags behave based on consent.

For this learning project, we keep things simple and do not implement full consent logic, but you should be aware of this when going to production.

5. How This Relates to Your Learning Platform

In this project:

  • The index.php page is your landing page.
  • When you later run Google Ads to this page:
    • Google will append ?gclid=... (and possibly wbraid / gbraid).
    • With the steps above, GTM / GA4 / your backend can:
      • Read them,
      • Store them,
      • Attach them to conversion events.

Recommended learning path

  1. Understand basic GTM + GA4 events using the current learning platform buttons.
  2. Create URL variables for gclid, wbraid, gbraid in GTM.
  3. Store them (localStorage/cookie) with the sample code above.
  4. Attach them to a custom conversion event in GTM.
  5. Later, when you run real ads, you'll already know how the IDs flow through your system.

6. Summary Table

Parameter Full Name Main Use Case Where It Lives
gclid Google Click Identifier Standard Google Ads web clicks URL param, cookie, events
wbraid Web-to-app / privacy ID Web-to-app & privacy-preserving tracking URL param, events
gbraid Google iOS/App Click ID iOS & app measurement URL param, events

๐Ÿ“š Related Documentation

๐Ÿ’ก Next Steps

Try adding the storeClickIds() function to your index.php page and see how the click IDs are detected and stored. Then configure GTM to read these values and attach them to your conversion events!