Link Code Generator Logo
Link Code Generator

Free GA4 Cross-Domain Tracking Code Generator

Generate Google Analytics 4 cross-domain tracking snippets to maintain user sessions across multiple domains. Paste the code and you're done.

Important GA4 Update: Google Analytics 4 highly recommends setting up cross-domain tracking via the Admin Data Streams UI rather than hardcoding it in standard deployments. However, if you are working within a complex custom CMS, using hardcoded gtag.js linkers is still supported and effective.

Found in your Google Analytics Admin panel under Data Streams.

Do not include `https://` or trailing slashes.

Enter your Analytics ID and the two distinct domains to generate the cross-domain tracking script.

Why GA4 Breaks Across Domains by Default

Google Analytics 4 identifies individual users by a cookie (_ga) stored on a specific domain. By default, this cookie only works on the domain that set it — it cannot be read by any other domain. This means when a visitor clicks from your main website (yourstore.com) to a separate checkout domain (checkout.yourstore.com or payment-processor.com), GA4 treats them as a brand new, anonymous visitor.

The impact: your funnel data is broken. You cannot see that a visitor who started on your homepage completed a purchase in your checkout. Your attribution data — paid ads, email campaigns, organic search — all appear to have zero conversions because the purchase happens on a different domain.

How GA4 Cross-Domain Linking Fixes This

GA4's cross-domain linker works by adding the user's client ID to the destination URL as a _gl= query parameter when they click a link crossing domains. The destination domain reads this parameter, recognizes the existing session, and continues tracking — no new session is started.

For this to work, both domains must have a GA4 tag installed, and both tags must list each other in the linker domains configuration. This tool generates the correctly configured gtag.js snippet for both domains.

Common Use Cases

  • E-commerce with External Checkout: Main marketing site on one domain, Shopify or custom checkout on another.
  • SaaS with Separate App Domain: Marketing site at company.com, web app at app.company.com or dashboard.company.com.
  • Microsite Campaigns: A campaign landing page hosted on a separate domain that feeds conversions to your main analytics dashboard.
  • Partner Referral Tracking: Tracking users who arrive from a partner portal on a different domain to your conversion destination.

Frequently Asked Questions

Does this work with subdomains?

Not exactly the same. Subdomains (like shop.yoursite.com and blog.yoursite.com) still share the same apex domain cookie, so GA4 handles them automatically without cross-domain linking. Cross-domain linking is only necessary when crossing between completely different TLD registrations (e.g. yoursite.com to yourcheckout.io).

Can I configure this in the GA4 UI instead?

Yes, GA4 Admin lets you add cross-domain domains under Property Settings → Data Streams → Your stream → Configure tag settings → Configure your domains. However, generating the snippet directly in the gtag.js code (as this tool does) ensures the configuration is always applied, even if the Google Tag Manager setup changes or a developer overwrites the stream settings.

Does cross-domain tracking violate GDPR or CCPA?

Cross-domain tracking does not inherently violate privacy regulations — it simply preserves session continuity for users who have already consented to analytics tracking. However, your privacy policy must disclose tracking across domains you operate. Ensure your cookie consent banner applies to all linked domains before implementing.

Developer tools delivered free

Deep link guides, Open Graph tips, and new dev tools — straight to your inbox.

All Tools Directory

Every free tool, in one place. Perfect for anyone who needs to create QR codes, build UTM-tagged links, generate contact links, or manage campaign URLs. No account required.

Amazon Affiliate Link Builder

Clean up messy Amazon URLs and generate perfect Associate links using your affiliate tag.

Link Expirator & Countdown Snippet

Generate a Javascript snippet to automatically expire a link and redirect traffic after a specific date and time.

Link Cloaker & Redirect

Generate HTML, PHP, and .htaccess redirect codes to hide ugly affiliate links.

Link Rotator

Generate a JavaScript snippet to randomly rotate traffic across multiple destination URLs based on percentage weights.

A/B Split Tester

Generate a Javascript snippet to split landing page traffic between two URLs for A/B testing.

URL Shortener

Instantly shorten long URLs to display clean links on social media.

UTM Link Builder

Easily add UTM parameters to URLs so you can track Custom Campaigns in Google Analytics.

SMS Link Generator

Create clickable sms: links that open the native text message app with a phone number and pre-filled message. Generates the URL and HTML code.

Mailto Link

Create advanced email links with pre-filled subjects, CC, BCC, and body text. Generates standard URLs and HTML code.

Direct Review Link

Generate direct 5-star review links for Google My Business, Yelp, Facebook, and Trustpilot to send to your customers.

Social Share Link

Create 1-click sharing links for Twitter, Facebook, LinkedIn, Reddit, and more. Generate custom URLs and HTML buttons.

Telegram Link

Create direct Telegram links using a username or phone number. Generates t.me URLs and HTML code.

WhatsApp Link

Create click-to-chat WhatsApp links with pre-filled messages. Generates wa.me URLs and HTML code.

Barcode (1D)

Generate, preview, and download 1D barcodes (Code128, EAN-13, UPC, etc.) instantly in your browser.

GA4 Cross-Domain Tracker

Generate Google Analytics 4 (GA4) cross-domain tracking code snippets to maintain user sessions across multiple websites.

Smart App Deep Link

Generate smart routing scripts that detect the user OS and redirect to native mobile apps falling back to web URLs.

HTML Link

Generate clean, perfectly formatted HTML anchor tags with custom rel, target, class, and ID attributes.

Open Graph Meta Tag

Generate the perfect Open Graph and Twitter Card HTML meta tags for social media link sharing optimization.

Payment URL

Generate unified deep links to accept payments via PayPal, Venmo, and Cash App.

QR Code Generator

Create custom QR codes with colors, logos, and multiple export formats.

WiFi QR Code

Create a WiFi QR code for your home or business. Guests scan to connect instantly — no password typing needed.

vCard QR Code

Create a vCard QR code for your business cards. Seamlessly share contact info straight to their phone book.

Social Media QR Code

Generate a QR code linked to your Instagram, Twitter, or TikTok.

Payment QR Code

Generate a payment QR code for Venmo, PayPal, or Stripe.

Event QR Code

Generate an iCalendar Event QR code for your invitations.

Location QR Code

Generate a QR code for a physical location mapping.

Email QR Code

Generate a mailto QR code.

Phone Call QR Code

Generate a phone call QR code.

SMS QR Code

Generate an SMS text message QR code.

App Store QR Code

Generate a QR code to link to your app on the App Store or Google Play.

Universal Location & Maps Link

Generate universal smart routing scripts and direct deep links for Google Maps, Apple Maps, and Waze.