关于Google Analytics跨域跟踪中utm自定义广告系列无法归因电商交易的咨询
Yep, this is a super common gotcha with cross-domain tracking in Google Analytics—even when you’ve got the _ga cookie sharing and session continuity locked in, UTM parameters don’t automatically carry over across domains by default. Lots of folks run into this exact issue, so you’re definitely not alone.
Why this happens
UTM parameters are tied to the initial session’s campaign data on the first domain. When a user jumps to your second domain, GA will default to treating that visit as a "direct" session unless you explicitly:
- Pass the UTM parameters along with the cross-domain link, or
- Configure GA to retain and reuse the original campaign attribution data across the session.
Fixes to try
1. Manually pass UTM parameters in cross-domain links
The most straightforward solution is to pull the UTM params from the user’s current URL on the first domain and append them to any links pointing to your second domain. Here’s a quick JavaScript snippet you can use:
// Extract UTM parameters from the current page URL function getUTMParams() { const urlParams = new URLSearchParams(window.location.search); const utmParams = {}; // Grab all parameters starting with "utm_" for (const [key, value] of urlParams.entries()) { if (key.startsWith('utm_')) { utmParams[key] = value; } } return utmParams; } // Append UTM params to all cross-domain links document.querySelectorAll('a[href^="https://your-second-domain.com"]').forEach(link => { const utmData = getUTMParams(); if (Object.keys(utmData).length > 0) { const targetUrl = new URL(link.href); // Add each UTM param to the target URL Object.entries(utmData).forEach(([key, val]) => { targetUrl.searchParams.set(key, val); }); link.href = targetUrl.toString(); } });
Just swap out https://your-second-domain.com with your actual second domain, and this will auto-add the original UTM params to any cross-domain links.
2. Retain campaign data via GA4 user properties (if using GA4)
If you’re on GA4, you can store the original campaign data as a user property on the first domain, then reference that property when sending purchase events on the second domain.
On your first domain, add this to your GA4 setup to capture the campaign data:
// Capture original UTM data as user properties gtag('set', 'user_properties', { original_utm_source: gtag('get', 'session', 'campaign.source'), original_utm_medium: gtag('get', 'session', 'campaign.medium'), original_utm_campaign: gtag('get', 'session', 'campaign.name') });
Then, when you send the purchase event on the second domain, include these user properties as custom dimensions. This lets you report on purchases tied back to the original UTM campaign, even if the params weren’t passed in the URL.
3. Double-check your cross-domain measurement setup
While this won’t directly fix UTM attribution, making sure your cross-domain configuration is complete ensures the session is properly linked between domains. For GA4, verify:
- Both domains are listed in Admin > Data Streams > Web > Configure tag settings > Cross-domain measurement
- The linker parameter is being automatically appended to cross-domain links (this is enabled by default when you add domains to cross-domain settings)
For Universal Analytics, confirm you’ve set allowLinker: true in your tracker config and are using linker:autoLink() to handle cross-domain links.
内容的提问来源于stack exchange,提问作者Griffin Pair

