Working with the Measurement Protocol - Google Developers

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

&ev=300 // Event value. View this hit in the Measurement Protocol Hit Builder. Enhanced Ecommerce Tracking. Important: Enhanced Ecommerce parameters must be ... Google Analytics Measurement MeasurementProtocol(UniversalAnalytics) Language English BahasaIndonesia Deutsch Español Français Português–Brasil Русский 中文–简体 日本語 한국어 Signin Guides Reference Support Google Analytics Measurement MeasurementProtocol(UniversalAnalytics) Guides Reference Support Overview Fundamentals WorkingwiththeMeasurementProtocolValidatingHitsEmailTracking Resources Protocol/SDK/UserIDPolicyLimitsandQuotas Demos&Tools HitBuilder ThisdocumentationisforUniversalAnalytics.SeeMeasurementProtocol(GoogleAnalytics4)ifyouareusingGoogleAnalytics4. Home Products GoogleAnalytics Measurement MeasurementProtocol(UniversalAnalytics) WorkingwiththeMeasurementProtocol ThisdocumentdescribeshowtosendcommonhitstotheMeasurementProtocol. Overview ThisdocumentdemonstrateshowtoformatHTTPrequeststosendcommon hittypestotheGoogleAnalyticsMeasurementProtocol.Readthe: Protocolreference –acompletedescriptionofhowtoformatProtocolrequests. Parameterreference –alistofalltheparametersacceptedbytheProtocol. Note:Theexamplesbelowareformattedto makeiteasiertoreadwhichProtocolparametersarebeingset.However, whensendingdata,allparametersmustbeonthesameline, havenospacesbetweenthem,andnotincludecomments.Readthe parameterreferencefortheformatofeachparameter. SendingRequiredValues Tosenduserinteractiondata,makeanHTTPPOSTrequesttothisendpoint. POST/collectHTTP/1.1 Host:www.google-analytics.com payload_data Thefollowingparametersarerequiredforeachpayload: v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=//HitType. Eachpayloadmustcontainavalidhittypeandeachhittypehas itsownsetofrequiredfields.Sotosendapageviewforthe /homepage,youwouldusethefollowingpayload: v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fhome Thesectionsbelowgiveexamplesofcommonhittypes. Batchingmultiplehitsinasinglerequest Tosendmultiplehitsinasinglerequest,usethe/batchendpointinsteadof/collectandspecifyeachpayloadonitsownline. Forexample,tosendpageviewhitsforthe"Home","AboutUs",and"Contact"pagesofawebsite,youcouldsendthefollowingbatchrequest. POST/batchHTTP/1.1 Host:www.google-analytics.com v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fhome v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fabout v=1&tid=UA-XXXXX-Y&cid=555&t=pageview&dp=%2Fcontact Batchlimitations InadditiontothestandardlimitationsofMeasurementProtocolhits,batchrequestshavethefollowingadditionallimitations: Amaximumof20hitscanbespecifiedperrequest. Thetotalsizeofallhitpayloadscannotbegreaterthan16Kbytes. Nosinglehitpayloadcanbegreaterthan8Kbytes. SendingCommonHitTypes BelowareexamplesofhowtosendcommonhittypestoGoogleAnalytics. Besidestheseexamples,youcanmixandmatchvariousparameters toachievenewdatarelationships.Forexample,tounderstandon whichpageaneventoccurred,sendthepagePathparameter, p,alongwitheventtrackingparametersasdescribedbelow. Readthe parameterreferenceforafulllistofallthe parametersyoucansendtoGoogleAnalytics. PageTracking v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=pageview//Pageviewhittype. &dh=mydemo.com//Documenthostname. &dp=/home//Page. &dt=homepage//Title. Viewthishitinthe MeasurementProtocolHitBuilder. EventTracking v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=event//Eventhittype &ec=video//EventCategory.Required. &ea=play//EventAction.Required. &el=holiday//Eventlabel. &ev=300//Eventvalue. Viewthishitinthe MeasurementProtocolHitBuilder. EnhancedEcommerceTracking Important: EnhancedEcommerceparameters mustbesentwithanexistinghit(e.g.pageview,event),butcannot besentwiththeEcommercetransactionoritem hittypes. EnhancedEcommercehitsshouldbeusedinplaceofEcommerce hits.Ifyou'vealreadyimplementedEcommercetrackingandwanttostartusing EnhancedEcommercetrackingtherearetwooptions: Useanewproperty Youcancreateanewpropertyandsend EnhancedEcommercehitstothenewproperty. Migrateanexistingproperty MigrateanyEcommercehitstoEnhancedEcommercehits,following theexamplesbelow.TransactionanditemdatapreviouslycollectedusingEcommerce hitswillnotbeaffectedandwillremainavailableinthe propertiesandviewstowhichtheywereoriginallysent. MeasuringImpressions v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=pageview//Pageviewhittype. &dh=mydemo.com//Documenthostname. &dp=/home//Page. &dt=homepage//Title. &il1nm=Search%20Results//Impressionlist1.Required. &il1pi1id=P12345//ProductImpression1ID.EitherIDornamemustbeset. &il1pi1nm=Android%20Warhol%20T-Shirt//ProductImpression1name.EitherIDornamemustbeset. &il1pi1ca=Apparel%2FT-Shirts//ProductImpression1category. &il1pi1br=Google//ProductImpression1brand. &il1pi1va=Black//ProductImpression1variant. &il1pi1ps=1//ProductImpression1position. &il1pi1cd1=Member//Customdimension. &il2nm=Recommended%20Products//Impressionlist2. &il2pi1nm=Yellow%20T-Shirt//ProductImpression1name. &il2pi2nm=Red%20T-Shirt//ProductImpression2name. Viewthishitinthe MeasurementProtocolHitBuilder. MeasuringActions v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=event//Eventhittype. &ec=UX//EventCategory.Required. &ea=click//EventAction.Required. &el=Results//Eventlabel. &pa=click//Productaction(click).Required. &pal=Search%20Results//ProductActionList. &pr1id=P12345//Product1ID.EitherIDornamemustbeset. &pr1nm=Android%20Warhol%20T-Shirt//Product1name.EitherIDornamemustbeset. &pr1ca=Apparel//Product1category. &pr1br=Google//Product1brand. &pr1va=Black//Product1variant. &pr1ps=1//Product1position. Viewthishitinthe MeasurementProtocolHitBuilder. CombiningImpressionsandActions v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=event//Eventhittype. &ec=UX//EventCategory.Required. &ea=click//EventAction.Required. &el=Results//Eventlabel. &pa=detail//Productaction(detail).Required. &pr1id=P12345//Product1ID.EitherIDornamemustbeset. &pr1nm=Android%20Warhol%20T-Shirt//Product1name.EitherIDornamemustbeset. &pr1ca=Apparel//Product1category. &pr1br=Google//Product1brand. &pr1va=Black//Product1variant. &pr1ps=1//Product1position. &il1nm=Related%20Products//Impressionlist. &il1pi1id=P12345//ProductImpression1ID. &il1pi1nm=Android%20Warhol%20T-Shirt//ProductImpression1name. &il1pi1ca=Apparel%2FT-Shirts//ProductImpression1category. &il1pi1br=Google//ProductImpression1brand. &il1pi1va=Black//ProductImpression1variant. &il1pi1ps=1//ProductImpression1position. Viewthishitinthe MeasurementProtocolHitBuilder. MeasuringPurchases v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=pageview//Pageviewhittype. &dh=mydemo.com//Documenthostname. &dp=/receipt//Page. &dt=Receipt%20Page//Title. &ti=T12345//TransactionID.Required. &ta=Google%20Store%20-%20Online//Affiliation. &tr=37.39//Revenue. &tt=2.85//Tax. &ts=5.34//Shipping. &tcc=SUMMER2013//Transactioncoupon. &pa=purchase//Productaction(purchase).Required. &pr1id=P12345//Product1ID.EitherIDornamemustbeset. &pr1nm=Android%20Warhol%20T-Shirt//Product1name.EitherIDornamemustbeset. &pr1ca=Apparel//Product1category. &pr1br=Google//Product1brand. &pr1va=Black//Product1variant. &pr1ps=1//Product1position. Viewthishitinthe MeasurementProtocolHitBuilder. MeasuringRefunds Ifyouneedtosendrefunddatausinganeventandtheeventisnotpartof normallymeasuredonsitebehavior(i.e.notuserinitiated),thenit’s recommendedthatyousenda non-interactionevent.Thiswillpreventmetricssuchasbouncerate, sessionduration,etc.frombeingaffectedbytheevent. //Refundanentiretransactionandsendwithanon-interactionevent. v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=event//Eventhittype. &ec=Ecommerce//EventCategory.Required. &ea=Refund//EventAction.Required. &ni=1//Non-interactionparameter. &ti=T12345//TransactionID.Required. &pa=refund//Productaction(refund).Required. Viewthishitinthe MeasurementProtocolHitBuilder. //Refundasingleproduct. v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=event//Eventhittype. &ec=Ecommerce//EventCategory.Required. &ea=Refund//EventAction.Required. &ni=1//Non-interactionparameter. &ti=T12345//TransactionID.Required. &pa=refund//Productaction(refund).Required. &pr1id=P12345//Product1ID.Required. &pr1qt=1//Product1quantity.Required. Viewthishitinthe MeasurementProtocolHitBuilder. MeasuringtheCheckoutProcess 1.MeasuringCheckoutSteps v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=pageview//Pageviewhittype. &dh=mydemo.com//Documenthostname. &dp=/checkout//Page. &dt=Checkout//Title. &pa=checkout//Productaction(checkout). &pr1id=P12345//Product1ID.EitherIDornamemustbeset. &pr1nm=Android%20Warhol%20T-Shirt//Product1name.EitherIDornamemustbeset. &pr1ca=Apparel//Product1category. &pr1br=Google//Product1brand. &pr1va=Black//Product1variant. &pr1pr=29.20//Product1Price. &pr1qt=1//Product1quantity. &cos=1//Checkoutstep#1. &col=Visa//Checkoutstepoption. Viewthishitinthe MeasurementProtocolHitBuilder. 2.MeasuringCheckoutOptions v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=event//Eventhittype &ec=Checkout//EventCategory.Required. &ea=Option//EventAction.Required. &pa=checkout_option//Productaction(checkout_option). &cos=2//Checkoutstep. &col=FedEx//Checkoutstepoption. Viewthishitinthe MeasurementProtocolHitBuilder. MeasuringInternalPromotions PromotionImpressions v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=pageview//Pageviewhittype. &dh=mydemo.com//Documenthostname. &dp=/home//Page. &dt=homepage//Title. &promo1id=PROMO_1234//Promotion1ID.EitherIDornamemustbeset. &promo1nm=Summer%20Sale//Promotion1name.EitherIDornamemustbeset. &promo1cr=summer_banner2//PromotionCreative. &promo1ps=banner_slot1//PromotionPosition. Viewthishitinthe MeasurementProtocolHitBuilder. PromotionClicks v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=event//Eventhittype &ec=Internal%20Promotions//EventCategory.Required. &ea=click//EventAction.Required. &el=Summer%20Sale//Eventlabel. &promoa=click//Promotionaction(click).Required. &promo1id=PROMO_1234//Promotion1ID.EitherIDornamemustbeset. &promo1nm=Summer%20Sale//Promotion1name.EitherIDornamemustbeset. &promo1cr=summer_banner2//PromotionCreative. &promo1ps=banner_slot1//PromotionPosition. Viewthishitinthe MeasurementProtocolHitBuilder. EcommerceTracking Tosendecommercedata,sendonetransactionhitto representanentiretransaction,thensendanitemhit foreachiteminthetransaction.ThetransactionIDti linksallthehitstogethertorepresenttheentirepurchase. TransactionHit v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=transaction//Transactionhittype. &ti=12345//transactionID.Required. &ta=westernWear//Transactionaffiliation. &tr=50.00//Transactionrevenue. &ts=32.00//Transactionshipping. &tt=12.00//Transactiontax. &cu=EUR//Currencycode. Viewthishitinthe MeasurementProtocolHitBuilder. ItemHit v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=item//Itemhittype. &ti=12345//TransactionID.Required. &in=sofa//Itemname.Required. &ip=300//Itemprice. &iq=2//Itemquantity. &ic=u3eqds43//Itemcode/SKU. &iv=furniture//Itemvariation/category. &cu=EUR//Currencycode. Viewthishitinthe MeasurementProtocolHitBuilder. SocialInteractions v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=social//Socialhittype. &sa=like//SocialAction.Required. &sn=facebook//SocialNetwork.Required. &st=/home//SocialTarget.Required. Viewthishitinthe MeasurementProtocolHitBuilder. ExceptionTracking v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=exception//Exceptionhittype. &exd=IOException//Exceptiondescription. &exf=1//Exceptionisfatal? Viewthishitinthe MeasurementProtocolHitBuilder. UserTimingTracking v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=timing//Timinghittype. &utc=jsonLoader//Timingcategory. &utv=load//Timingvariable. &utt=5000//Timingtime. &utl=jQuery//Timinglabel. //Thesevaluesarepartofbrowserloadtimes &dns=100//DNSloadtime. &pdt=20//Pagedownloadtime. &rrt=32//Redirecttime. &tcp=56//TCPconnecttime. &srt=12//Serverresponsetime. Viewthishitinthe MeasurementProtocolHitBuilder. App/ScreenTracking v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=screenview//Screenviewhittype. &an=funTimes//Appname. &av=1.5.0//Appversion. &aid=com.foo.App//AppId. &aiid=com.android.vending//AppInstallerId. &cd=Home//Screenname/contentdescription. Viewthishitinthe MeasurementProtocolHitBuilder. UsingaProxyServer SomeenvironmentsarenotabletosendhitstoGoogleAnalyticsdirectly.Examplesofthis areoldermobilephonesthatcan'trunJavaScriptorcorporateintranetsbehindafirewall. Inthesecasesit'scommontosendrequeststoaproxyserverthatthenusestheMeasurement ProtocoltoforwardthehitsontoGoogleAnalytics. TocollecttheIPanduseragentfromtheclientdeviceandnottheproxyserver,youcan specifybothvaluesinthemeasurementprotocol,andtheywilloverridethevaluesGoogle Analyticsnormallyobtainsfromtherequestheaders. v=1//Version. &tid=UA-XXXXX-Y//TrackingID/PropertyID. &cid=555//AnonymousClientID. &t=pageview//Pageviewhittype. &uip=1.2.3.4//IPaddressoverride. &ua=Opera/9.80//Useragentoverride. Viewthishitinthe MeasurementProtocolHitBuilder. Note: ItisimportantthatyouusevaliduseragentstringssothatGoogleAnalyticscanproperly identifyanddisplayuseragentinformationinreports.Handcraftingyourowncouldbreak atanytime. Exceptasotherwisenoted,thecontentofthispageislicensedundertheCreativeCommonsAttribution4.0License,andcodesamplesarelicensedundertheApache2.0License.Fordetails,seetheGoogleDevelopersSitePolicies.JavaisaregisteredtrademarkofOracleand/oritsaffiliates. Lastupdated2021-06-10UTC. [{ "type":"thumb-down", "id":"missingTheInformationINeed", "label":"MissingtheinformationIneed" },{ "type":"thumb-down", "id":"tooComplicatedTooManySteps", "label":"Toocomplicated/toomanysteps" },{ "type":"thumb-down", "id":"outOfDate", "label":"Outofdate" },{ "type":"thumb-down", "id":"samplesCodeIssue", "label":"Samples/codeissue" },{ "type":"thumb-down", "id":"otherDown", "label":"Other" }] [{ "type":"thumb-up", "id":"easyToUnderstand", "label":"Easytounderstand" },{ "type":"thumb-up", "id":"solvedMyProblem", "label":"Solvedmyproblem" },{ "type":"thumb-up", "id":"otherUp", "label":"Other" }] GitHub TryGoogleAnalyticssamples StackOverflow Askquestionsusingthegoogle-analyticstag Twitter Follow@googleanalyticsonTwitter Videos ViewGoogleAnalyticsvideosonYouTube Connect Community&Updates GettingHelp ReportinganIssue ProductInfo Protocol/SDKPolicy BrandingPolicy Developerconsoles GoogleAPIConsole GoogleCloudPlatformConsole GooglePlayConsole FirebaseConsole ActionsonGoogleConsole CastSDKDeveloperConsole ChromeWebStoreDashboard Android Chrome Firebase GoogleCloudPlatform Allproducts Terms Privacy SignupfortheGoogleDevelopersnewsletter Subscribe Language English BahasaIndonesia Deutsch Español Français Português–Brasil Русский 中文–简体 日本語 한국어



請為這篇文章評分?