Google Ads Cross-Domain Tracking | OpsBlu Docs

Google Ads Cross-Domain Tracking

Configure cross-domain tracking for Google Ads conversions across multiple domains.

Overview

Cross-domain tracking enables Google Ads to maintain click attribution when users navigate between multiple domains in your conversion funnel. This is essential for scenarios like:

  • Main website to separate checkout domain
  • Marketing site to application subdomain
  • Multiple country-specific domains
  • Third-party payment processors

Implementation Methods

Configure automatic cross-domain linking in the global site tag:

gtag('config', 'AW-CONVERSION_ID', {
  'linker': {
    'domains': ['example.com', 'checkout.example.com', 'app.example.com']
  }
});

This automatically appends _gl parameter to links between specified domains, preserving the GCLID.

Google Tag Manager Setup

  1. Create new Variable: Auto-Link Domains
  2. Type: Auto-Link Domains
  3. Add domains: example.com, checkout.example.com
  4. Check "Use hash as delimiter"
  5. Check "Decorate forms"

Step 2: Update Google Ads Tag

  1. Open Google Ads Conversion Tracking tag
  2. Enable "Cross-Domain Tracking"
  3. Select the Auto-Link Domains variable
  4. Save and publish

Step 3: Configure All Domains

Repeat configuration on all domains in the funnel with the same domain list.

For specific links that need decoration:

// Decorate a specific link
var link = document.getElementById('checkout-link');
var linker = new gtag.Linker(['example.com', 'checkout.example.com']);
link.href = linker.decorate(link.href);

Form Decoration

Automatically decorate forms that submit to other domains:

gtag('config', 'AW-CONVERSION_ID', {
  'linker': {
    'domains': ['example.com', 'checkout.example.com'],
    'decorate_forms': true
  }
});

Third-Party Payment Processors

PayPal, Stripe, Square

For payment processors that redirect users:

  1. Add payment processor domain to linker domains (if they allow)
  2. Implement return URL tracking
  3. Use server-side conversion tracking as backup

Note: Most payment processors don't allow JavaScript execution, making client-side cross-domain tracking impossible. Use server-side conversion imports instead.

// Track before redirect to payment processor
gtag('event', 'begin_checkout', {
  'send_to': 'AW-CONVERSION_ID',
  'transaction_id': 'TXN_12345',
  'value': 99.99,
  'currency': 'USD'
});

// Server-side: Import conversion after payment confirmation
// Use Google Ads API to upload offline conversions with GCLID

Subdomain Tracking

For subdomains (e.g., www.example.com and app.example.com):

gtag('config', 'AW-CONVERSION_ID', {
  'cookie_domain': '.example.com', // Note the leading dot
  'linker': {
    'domains': ['www.example.com', 'app.example.com']
  }
});

The leading dot (.example.com) allows cookies to be shared across all subdomains.

Multiple Top-Level Domains

For separate TLDs (e.g., example.com and example.co.uk):

gtag('config', 'AW-CONVERSION_ID', {
  'linker': {
    'domains': ['example.com', 'example.co.uk', 'example.de'],
    'accept_incoming': true
  }
});

Deploy this configuration on all domains with the complete list.

Testing Cross-Domain Tracking

  1. Navigate to source domain
  2. Click link to destination domain
  3. Check URL contains _gl parameter: https://checkout.example.com/?_gl=1*abc123...

Verify GCLID Transfer

  1. Click Google Ad with test GCLID
  2. Navigate across domains
  3. Check GCLID persists in cookies and URL parameters
  4. Use Google Tag Assistant to verify

Chrome Console Test

// Check if linker is working
document.querySelectorAll('a').forEach(link => {
  if (link.href.includes('_gl=')) {
    console.log('Decorated link:', link.href);
  }
});

GTM Preview Mode Testing

  1. Enable GTM Preview mode on source domain
  2. Click through to destination domain
  3. Verify GTM Preview continues on destination
  4. Check Data Layer for GCLID values
  5. Confirm conversions fire with correct attribution

Common Issues & Solutions

_gl Parameter Not Appearing

Causes:

  • Domains not configured in linker settings
  • JavaScript loading after link click
  • Conflicting scripts removing URL parameters

Solutions:

  • Verify domain list includes all domains (with and without www)
  • Load gtag.js in <head> before content
  • Check for URL sanitization scripts

GCLID Not Persisting

Causes:

Solutions:

  • Set cookie_domain correctly for subdomains
  • Use first-party cookies only
  • Extend GCLID cookie lifetime:
gtag('config', 'AW-CONVERSION_ID', {
  'cookie_expires': 7776000 // 90 days in seconds
});

Conversions Not Attributed

Causes:

  • GCLID lost during redirect
  • Conversion fires before GCLID extracted
  • Missing accept_incoming parameter

Solutions:

  • Add accept_incoming: true to linker config
  • Delay conversion tag until GCLID is processed
  • Implement server-side conversion tracking

Advanced Configuration

Conditional Cross-Domain Tracking

Only decorate links to specific domains:

document.addEventListener('click', function(event) {
  var link = event.target.closest('a');
  if (link && link.hostname === 'checkout.example.com') {
    var linker = new gtag.Linker(['checkout.example.com']);
    link.href = linker.decorate(link.href);
  }
});

SPA (Single Page Application) Tracking

For React, Vue, Angular apps:

// Update linker on route change
router.afterEach((to, from) => {
  gtag('config', 'AW-CONVERSION_ID', {
    'page_path': to.path,
    'linker': {
      'domains': ['example.com', 'app.example.com']
    }
  });
});

Server-Side Cross-Domain Tracking

For server-rendered applications:

  1. Extract GCLID from URL or cookie server-side
  2. Store in session or database
  3. Include in conversion API calls
  4. Use Google Ads API for offline conversion import
# Python example
from flask import request, session

@app.route('/checkout')
def checkout():
    gclid = request.args.get('gclid') or request.cookies.get('_gcl_aw')
    if gclid:
        session['gclid'] = gclid
    return render_template('checkout.html')

@app.route('/conversion')
def conversion():
    gclid = session.get('gclid')
    if gclid:
        # Send conversion to Google Ads API with GCLID
        send_offline_conversion(gclid, conversion_data)

Best Practices

  • Include all domains in the linker configuration, including www and non-www versions
  • Test cross-domain tracking in staging before production deployment
  • Use accept_incoming: true on all domains to receive decorated links
  • Set cookie_domain for subdomain tracking
  • Monitor conversion attribution in Google Ads reports
  • Document your cross-domain setup for future reference
  • Use server-side tracking for critical conversions
  • Implement both client-side and server-side tracking for redundancy
  • Regularly test link decoration after site updates
  • Consider using Google Analytics 4 cross-domain tracking in parallel for validation