[GA4] Set up cross-domain measurement - Analytics Help

文章推薦指數: 80 %
投票人數:10人

Verify that the URL in the destination domain contains the linker parameter _gl ; for example: https://www.example.com/?_gl=1*abcde5* . Troubleshooting. If you ... Skiptomaincontent[GA4]Setupcross-domainmeasurementThisarticleisforwebsiteownerswhoneedunifiedmeasurementacrossmorethanonedomain,e.g.acrossacustomerwebsiteandaseparateshoppingcartdomain.ThisarticlepertainstoGoogleAnalytics4properties;ifyouareusingUniversalAnalytics,readthisarticleinstead. Cross-domainmeasurementallowsactivitytobeaccuratelyattributedtoasingleuserastheycrossdomains.Outboundclicksthatwouldordinarilytriggeraneventvia enhancedmeasurementareignoredwhentheoutboundlink leadstoadomainthatyou'velistedaspartofcross-domainmeasurement. Videooverview CrossDomainMeasurementinGoogleAnalytics4Properties   Cookiesandcross-domainmeasurement Analyticsusesfirst-partycookiestosetanidentifierforeachuniqueuserandsessiontoawebsite. Withoutcross-domainmeasurement,newcookieswithnewidentifiersaresetforeachdomainauservisits.Analyticscountthesenewcookieswithnewidentifiers asseparateuserswithseparatesessions. Withcross-domainmeasurement,thesameidentifiersarepassed fromonesitetoanotherviaaURLparameteridentifiedbythekey_gl:,forexample:https://www.example.com/?_gl=1*abcde5*. Ifyoualsohavea UniversalAnalyticsproperty ForyourUniversalAnalyticsproperty,youconfiguredcross-domainmeasurement viacode (eitherinthesourcecodethroughanalytics.jsorgtag.js,orviaGoogleTagManager).Foryour GoogleAnalytics4property,you'lldothisviatheAdminpage.Follow theinstructionsbelowtoaddthesamedomainsyou'veidentifiedinyourUniversalAnalyticspagecode. IfyouhaveanexistingconfigurationintheGoogletagforyourUniversalAnalyticsproperty,itwillbeappliedtoyourGoogleAnalytics4propertyaswell.Anydomainsyou'vespecifiedin thecodeorviathe Admin willapplytoyourGoogleAnalytics4property.However,werecommendthatyouconfigureintheAdmin only. Setupcross-domainmeasurementviatheAdmin YouneedtheEditorroletosetupcross-domainmeasurement. Checkyourtag(e.g.theGoogletagoneachof yourHTML pages)foreachdomainthatyouwanttoincludeinyourcross-domainmeasurement.Thetagoneachpagemustuse thesametagID(i.e.,thesame"G-"ID)fromthesamewebdatastream. InAdmin,click DataStreams inthe Property column. Click Web andthenclickawebdatastream. Inthewebstreamdetails,click Configuretagsettings (atthebottom). Inthe Settings section,click Configureyourdomains. UnderIncludedomainsthatmatchANYofthefollowingconditions: Chooseamatchtype. UnderDomain,entertheidentifierforthedomainyouwanttomatch(e.g.,example.com). ClickAddconditiontoaddthenextdomain.(Addeachdomainyouwanttoincludeincross-domainmeasurement.) ConditionsareevaluatedusingORlogic. ClickSave. Manualsetup Therecommendedapproachistoconfigurecross-domainmeasurementviatheAnalyticsinterface.However,theremightbescenarioswhereyouneedtoimplementacustomsolutionviathemeasurementcode.Inthesecases,youcansetitupmanuallybyusingthegetandsetcommandsofthegtag.jsAPItopersistIDsacrossdomains.Learnmoreaboutsettingupcross-domainmeasurementmanually. Example ToretrieveaclientIDonthesourcedomain,youusethegetmethod: gtag('get','TAG_ID','client_id',(client_id)=>{ //StoretheclientIDinavariable. }); gtag('get','TAG_ID','session_id',(session_id)=>{ //StorethesessionIDinavariable. }); OnceyouhavetheclientandsessionIDs,addthemtothelinkthatpointstothedestinationdomain: example.com   Onthedestinationpage,readtheIDsfromtheURLandsetthemwiththeconfigcommand: gtag('config','TAG_ID',{ 'client_id':getClientIdFromUrl(), 'session_id':getSessionIdFromUrl() }); Verifythatcross-domainmeasurementisworkingproperly Openapageofyoursitethatcontainsalinkoraformthatpointstoadomainyouconfiguredforcross-domainmeasurement. Clickthelinkorsubmittheformtonavigatetothedestinationdomain. VerifythattheURLinthedestinationdomaincontainsthelinkerparameter_gl;forexample:https://www.example.com/?_gl=1*abcde5*. Troubleshooting Ifyoucan'tconfirmthepresenceoftheparameter_gl intheURLofthedestinationdomainperthestepsabove,doublecheckthatthedomainyouconfiguredintheinterfacematchesthedomainyoursiteispointingto. It'salsopossiblethatyourwebsiteisconfiguredinawaythatpreventscross-domainmeasurementfromworkingcorrectly.Withthehelpofanexperiencedwebdeveloper,investigatewhetheryourwebsiteisbeingaffectedbythefollowingissues. URLredirects Ifthedestinationpageredirectsordoesn'tsupportarbitraryqueryparameters,theparameter_gl mayendupbeingremovedfromtheURLevenifitwasappendedbyAnalyticsinthepreviouspage.(Thisusuallyhappenstooquicklytoobservebyeye.)Toconfirmifthisishappeningtoyoursite,checkthenetworkrequestsmadebythepreviouspageusingtheChromeDeveloperTools.Tofixthisissue,configureyoursitetopreservetheparameter_gl inredirects. Conflictswithotherscripts Cross-domainmeasurementworksbycreatinganeventlisteneronthedocumentnodeofapage.Whenusersclickalink,theclickeventbubbles uptothedocumentnodeandtheparameter_gl isaddedtothelinkURL.Thisprocesscannotworkproperlyinthefollowingscenarios: WhenthenavigationistriggeredbyJavaScriptasopposedtoadirectresponsetoauseraction. Whencompetingscriptsinthepagestoptheeventpropagationbeforeitreachesthedocumentnode;forexample,whenEvent.stopPropagation()isused. Wasthishelpful?Howcanweimproveit?YesNoSubmitNeedmorehelp?Trythesenextsteps:AsktheHelpCommunityGetanswersfromcommunityexpertstrueSetupAnalyticsGetstartedwithAnalytics[GA4]SetupAnalyticsforaCMS-hostedwebsite[GA4]SetupAnalyticsforawebsiteand/orappSetupAnalyticsforawebsite(UniversalAnalytics)AddaGoogleAnalytics4property(toasitethatalreadyhasAnalytics)[GA4]SetupdatacollectionforanappTheGoogletag[GA4]Confirmthatyou'recollectingdata[GA4]MonitoreventsinDebugView[GA4]Setupcross-domainmeasurement[GA4]Identifyunwantedreferrals[GA4]Filteroutinternaltraffic[GA4]Filter,reporton,orrestrictaccesstodatasubsets[GA4]Aboutconnectedsitetags[GA4]URLbuilders:CollectcampaigndatawithcustomURLs[GA4]Setcustomcampaigndata[GA4]SetupAssistantinGoogleAnalytics4propertiesWhathappenedtomyTrackingID?[GA4]CommonmistakeswithtagsetupWhydoesGoogleAnalyticslookdifferent?GoogleAnalytics4trainingandsupportSearchClearsearchClosesearchGoogleappsMainmenuSearchHelpCentertrue69256falsefalse



請為這篇文章評分?