Enhanced ecommerce | Universal Analytics for Web (gtag.js)

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

This page describes how to use gtag.js to collect enhanced ecommerce data. ... To measure a transaction, send a purchase event with the items in the ... Google Analytics Measurement UniversalAnalytics(gtag.js) Language English BahasaIndonesia Deutsch Español Français Português–Brasil Русский 中文–简体 日本語 한국어 Signin Google Analytics Measurement UniversalAnalytics(gtag.js) Guides Getstarted Addgtag.jstoyoursiteSenddatatoGoogleAnalyticsSetpersistentvalues Measurecommonuserinteractions PageviewsEventsPhoneanalyticsApp/screenviewsUsertimingsExceptions Advanced CookiesanduseridentificationCross-domainmeasurementCustomdimensionsandmetricsDisableadvertisingfeaturesEnhancedecommerceEnhancedlinkattributionIPanonymizationRenametheglobalobjectDisableAnalyticsforopted-outusers Solutions CheckexceptionsandcustomdimensionsandmetricsSinglepageapplications Resources CookieusageLimitsandquotas Home Products GoogleAnalytics Measurement UniversalAnalytics(gtag.js) Enhancedecommerce Thispagedescribeshowtousegtag.jstocollectenhancedecommercedata.IfyouhaveconfiguredGoogleAnalyticsingtag.jsandyouhave enhancedecommerceenabledinGoogleAnalytics,youcanusegtag.jstosend impressiondata,productdata,promotiondata,andactiondatatoGoogle Analytics. EnhancedEcommerceDataTypesandActions Therearemultipletypesofecommercedatayoucansend: impressiondata productdata actiondata actiontypes ImpressionData Representsinformationaboutaproductthathasbeenviewed.Itisreferredto asanimpressionFieldObjectandcontainsthefollowingvalues: Key ValueType Required Description id text *Yes TheproductIDorSKU(e.g.P67890). *Oneofidornamemustbe set. name text *Yes Thenameoftheproduct(e.g.AndroidT-Shirt). *Oneofidornamemustbe set. list_name text No Thelistorcollectiontowhichtheproductbelongs(e.g.SearchResults) brand text No Thebrandassociatedwiththeproduct(e.g.Google). category text No Thecategorytowhichtheproductbelongs(e.g.Apparel).Use /asadelimitertospecifyupto5-levelsofhierarchy(e.g. Apparel/Men/T-Shirts). variant text No Thevariantoftheproduct(e.g.Black). list_position integer No Theproduct'spositioninalistorcollection(e.g.2). price number No Thepriceofaproduct(e.g.29.20). ProductData Productdatarepresentsindividualproductsthatwereviewed,addedtothe shoppingcart,etc.ItisreferredtoasaproductFieldObjectandcontainsthe followingvalues: Key ValueType Required Description id text *Yes TheproductIDorSKU(e.g.P67890). *Oneofidornamemustbe set. name text *Yes Thenameoftheproduct(e.g.AndroidT-Shirt). *Oneofidornamemustbe set. brand text No Thebrandassociatedwiththeproduct(e.g.Google). category text No Thecategorytowhichtheproductbelongs(e.g.Apparel).Use /asadelimitertospecifyupto5-levelsofhierarchy(e.g. Apparel/Men/T-Shirts). variant text No Thevariantoftheproduct(e.g.Black). price number No Thepriceofaproduct(e.g.29.20). quantity integer No Thequantityofaproduct(e.g.2). coupon text No Thecouponcodeassociatedwithaproduct(e.g.SUMMER_SALE13). list_position integer No Theproduct'spositioninalistorcollection(e.g.2). PromotionData Representsinformationaboutapromotionthathasbeenviewed.Itisreferredto apromoFieldObjectandcontainsthefollowingvalues: Key ValueType Required Description id text *Yes ThepromotionID(e.g.PROMO_1234). *Oneofidornamemustbe set. name text *Yes Thenameofthepromotion(e.g.SummerSale). *Oneofidornamemustbe set. creative_name text No Thenameofthecreative(e.g.summer_banner2). creative_slot text No Thenameofthecreativeslot(e.g.banner_slot_1). ActionData Representsinformationaboutanecommercerelatedactionthathastakenplace. ItisreferredtoasanactionFieldObjectandcontainsthefollowingvalues: Key ValueType Required Description id text *Yes ThetransactionID(e.g.T1234). *Requirediftheactiontypeispurchaseor refund affiliation text No Thestoreoraffiliationfromwhichthistransactionoccurred(e.g.Google Store). value number No Value(i.e.revenue)associatedwiththeevent. tax number No Thetotaltaxassociatedwiththetransaction. shipping number No Theshippingcostassociatedwiththetransaction. items array No Thearraycontainingtheassociatedproducts. checkout_step integer No Anumberrepresentingastepinthecheckoutprocess. checkout_option text No Checkoutoption(i.e.selectedpaymentmethod). Key ValueType Required Description coupon string No Couponcodeforapurchasableitem. ProductandPromotionActions Actionsspecifyhowtointerpretproductandpromotiondatathatyousendto GoogleAnalytics. Event Description add_to_cart Auseraddsoneormoreproductstoashoppingcart. begin_checkout Auserinitiatesthecheckoutprocessforoneormoreproducts. checkout_progress Ausercompletescheckoutstepsafterthefirstcheckoutstep. purchase Ausercompletesapurchase. refund Auserisissuedarefundforoneormoreproducts. remove_from_cart Auserremovesoneormoreproductsfromashoppingcart. select_content Auserclicksonaproductorproductlink. set_checkout_option Thecheckoutstepthatauseriscompleting. view_item Auserviewsdetailsforaproduct. view_item_list Auserviewsalistofoneormoreproducts. view_promotion Auserclicksonaninternalpromotion. view_refund Auserviewsarefundforoneormoreproducts. Examples Measureproductimpressions Tomeasureproductimpressions,sendaview_item_listwiththeproduct information: gtag('event','view_item_list',{ "items":[ { "id":"P12345", "name":"AndroidWarholT-Shirt", "list_name":"SearchResults", "brand":"Google", "category":"Apparel/T-Shirts", "variant":"Black", "list_position":1, "quantity":2, "price":2 }, { "id":"P67890", "name":"FlamechallengeTShirt", "list_name":"SearchResults", "brand":"MyBrand", "category":"Apparel/T-Shirts", "variant":"Red", "list_position":2, "quantity":1, "price":3 } ] }); Measureproductclicks Tomeasureaproductclick,sendaselect_contentevent,specifyproductas thecontent_type,andprovidetheproductinformation: gtag('event','select_content',{ "content_type":"product", "items":[ { "id":"P12345", "name":"AndroidWarholT-Shirt", "list_name":"SearchResults", "brand":"Google", "category":"Apparel/T-Shirts", "variant":"Black", "list_position":1, "quantity":2, "price":2 } ] }); Measureproductdetailviews Afterclickingaproductlisting,ausermightviewtheproductdetailspage.To measureproductdetailviews,sendaview_itemeventwiththeproductdetails: gtag('event','view_item',{ "items":[ { "id":"P12345", "name":"AndroidWarholT-Shirt", "list_name":"SearchResults", "brand":"Google", "category":"Apparel/T-Shirts", "variant":"Black", "list_position":1, "quantity":2, "price":'2.0' } ] }); Measureadditionstoandremovalsfromshoppingcarts Tomeasuretheadditionofaproducttoashoppingcart,sendanadd_to_cart eventwiththeproductinformation: gtag('event','add_to_cart',{ "items":[ { "id":"P12345", "name":"AndroidWarholT-Shirt", "list_name":"SearchResults", "brand":"Google", "category":"Apparel/T-Shirts", "variant":"Black", "list_position":1, "quantity":2, "price":'2.0' } ] }); Tomeasuretheremovalofaproductfromashoppingcart,sendan remove_from_carteventwiththeproductinformation: gtag('event','remove_from_cart',{ "items":[ { "id":"P12345", "name":"AndroidWarholT-Shirt", "list_name":"SearchResults", "brand":"Google", "category":"Apparel/T-Shirts", "variant":"Black", "list_position":1, "quantity":2, "price":'2.0' } ] }); Measurecheckouts Tomeasureeachstepinacheckoutprocess: Addmeasurementcodetomeasureeachstepofthecheckoutprocess. Ifapplicable,addmeasurementcodetorecordcheckoutoptions. 1.Measurecheckoutsteps Tomeasurethefirstcheckoutstep,sendabegin_checkouteventwiththe checkoutitems: gtag('event','begin_checkout',{ "items":[ { "id":"P12345", "name":"AndroidWarholT-Shirt", "list_name":"SearchResults", "brand":"Google", "category":"Apparel/T-Shirts", "variant":"Black", "list_position":1, "quantity":2, "price":'2.0' } ], "coupon":"" }); Tomeasureeachsubsequentcheckoutstep,sendacheckout_progresseventwith thecheckoutitems: gtag('event','checkout_progress',{ "items":[ { "id":"P12345", "name":"AndroidWarholT-Shirt", "list_name":"SearchResults", "brand":"Google", "category":"Apparel/T-Shirts", "variant":"Black", "list_position":1, "quantity":2, "price":'2.0' } ], "coupon":"SUMMER_DISCOUNT" }); 2.Measurecheckoutoptions Tomeasureacheckoutoption,sendaset_checkout_optioneventwiththe checkoutoption: gtag('event','set_checkout_option',{ "checkout_step":1, "checkout_option":"shippingmethod", "value":3 }); Measurepromotionimpressions Tomeasurepromotionimpressions,sendaview_promotioneventwithpromotion information: gtag('event','view_promotion',{ "promotions":[ { "id":"abc123", "name":"summer_promo" }, { "id":"xyz987", "name":"springsavings" } ] }); Measurepromotionclicks Tomeasureapromotionclick,sendaselect_contenteventandprovidethe promotion: gtag('event','select_content',{ "promotions":[ { "id":"abc123", "name":"summer_promo" } ] }); Measurepurchases Tomeasureatransaction,sendapurchaseeventwiththeitemsinthe transaction: gtag('event','purchase',{ "transaction_id":"24.031608523954162", "affiliation":"Googleonlinestore", "value":23.07, "currency":"USD", "tax":1.24, "shipping":0, "items":[ { "id":"P12345", "name":"AndroidWarholT-Shirt", "list_name":"SearchResults", "brand":"Google", "category":"Apparel/T-Shirts", "variant":"Black", "list_position":1, "quantity":2, "price":'2.0' }, { "id":"P67890", "name":"FlamechallengeTShirt", "list_name":"SearchResults", "brand":"MyBrand", "category":"Apparel/T-Shirts", "variant":"Red", "list_position":2, "quantity":1, "price":'3.0' } ] }); Measurerefunds Tomeasureafullrefundofatransaction,sendarefundeventwiththe transactionID: gtag('event','refund',{"transaction_id":"T12345"}) Tomeasureapartialrefund,sendarefundeventwiththetransactionIDand theitemstoberefunded: gtag('event','refund',{ "transaction_id":"79.18502354114992", "affiliation":"Googleonlinestore", "value":23.07, "currency":"USD", "tax":1.24, "shipping":0, "items":[ { "id":"P12345", "name":"AndroidWarholT-Shirt", "list_name":"SearchResults", "brand":"Google", "category":"Apparel/T-Shirts", "variant":"Black", "list_position":1, "quantity":2, "price":'2.0' }, { "id":"P67890", "name":"FlamechallengeTShirt", "list_name":"SearchResults", "brand":"MyBrand", "category":"Apparel/T-Shirts", "variant":"Red", "list_position":2, "quantity":1, "price":'3.0' } ] }); Exceptasotherwisenoted,thecontentofthispageislicensedundertheCreativeCommonsAttribution4.0License,andcodesamplesarelicensedundertheApache2.0License.Fordetails,seetheGoogleDevelopersSitePolicies.JavaisaregisteredtrademarkofOracleand/oritsaffiliates. Lastupdated2022-01-04UTC. [{ "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 Русский 中文–简体 日本語 한국어



請為這篇文章評分?