Implementation Guide For Events In Google Analytics 4

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

BigQuery export and GA4 events SimoAhava Husband|Father|Analyticsdevelopersimo(at)simoahava.com Home Categories Tags GTMTips About RSS Tools Blogstatistics GitHub Upcomingtalks Templates Newsletter ImplementationGuideForEventsInGoogleAnalytics4 November16,2020 in Analytics |Comments Onthesurface,trackingeventsinGoogleAnalytics4(GA4)isfairlysimple.Eventsare,afterall,prettymuchtheonlythingyoucancollectinGA4. It’seasytogettieddownwithendlesscomparisonstoUniversalAnalytics,though.WhileI’msteadfastlyopposedtotheideathatGA4shouldresembleUniversalAnalytics,it’sstillimportanttocleansethepalateandapproachGA4’seventtrackingwithanopenmind. Therearesomecomparisonsthatcanbedrawnbetweenthenewandtheold,butwhatGA4mightlackinsomefeaturesandusecases,itmorethanmakesupforthiswithamoreflexibledatastructure. Inthisimplementationguide,I’lltakealookatthestructure,composition,implementation,andevaluationofGoogleAnalytics4events. FormoredetailsonhoweventsworkinGoogleAnalytics4,docheckoutthefollowingexcellentresources: Officialsupportdocumentation Officialdeveloperdocumentation DigitalDebriefbyKristaSeiden CharlesFarina’sBlog KenWilliams’blog TheseresourcesoutmatchanythingIcouldcreatebyawidemargin,somakesureyoubookmarkthemandfollowthemreligiously! TableofContentsTableofContents [+show] [–hide] Structureofanevent EventtaginGoogleTagManager Quotasandlimits Enhancedmeasurement BigQueryexportandGA4events Eventtypes Automaticallycollectedevents Recommendedevents Customevents Eventparameters Specialparameters Customparameters Userproperties Configurationtagandevents Ecommerceevents Debuggingevents TagAssistantPreview Developertools DebugView Summary Thisguidewillbefocusedondatacollectionfortheweb,mainlyusingGoogleTagManager.Whilemobileappeventsandgtag.jsimplementationswillbediscussedinpassing,IhavechosenthisparticularfocusduetotheoverwhelmingpopularityofGoogleTagManagerastheprimarymeansforcollectingdatatoGoogleAnalytics. X TheSimmerNewsletter SubscribetotheSimmernewslettertogetthelatestnewsandcontentfromSimoAhavaintoyouremailinbox! Structureofanevent Aneventhit,whensenttoGA4,comprisesaneventnameandparameters. Furthermore,parameterscanbedividedintoautomaticallycollectedparametersandcustomparameters. Forexample,hereisaneventnamedpage_view,sentwithabunchofparameterstoGA4: Thereareahandfulofspecial(reserved)parameterscollectedformeasurement,suchas: tid-MeasurementID sr-Screenresolution _dbg-Debugmodeactive seg-Userisconsideredengagedforthissession Therearemoredetailsabouttheseautomaticallycollectedparametersinalaterchapter. I’malsosendingacoupleofcustomparameters: epn.readibility_median_grade-Acustomparametersentasanumber. epn.readability_reading_time-Acustomparametersentasanumber. Theprefixepnmeansanumberparameter,whereastheprefixepmeansatextparameter. Here’sanexampleofaneventthatsendstextparametersanduserproperties(prefixedwithup): NotethatGA4batchesevents,soifyoufiremorethanoneeventinaveryshorttimewindow,theeventswillbesenttogetherinasinglehit: Thehitabovesenttwoevents:apage_vieweventandascrollevent,bothwithsomecustomparameters. Inthisarticle,I’llhelpyoucometotermswiththeterminologyusedabove. EventtaginGoogleTagManager WhileGoogleAnalytics4implementationviaGoogleTagManagerisstillsomewhatinbeta(evenifGA4itselfisn’t),it’sstillmorethanpossibletosetanentireGA4implementationupwithGTM. GTMhastwotagtypesforcollectingdatatoGoogleAnalytics4. GoogleAnalytics:GA4Configuration-RecommendedforGA4datacollection.Establishesthebasesettingsandisusedastheunderlyingconfigurationforeventtags. GoogleAnalytics:GA4Event-TagtypeusedforsendingeventstoGA4. InordertosendyourcustomeventhitstoGA4,youneedtoestablishaconfigurationfirst.Youcancheckoutmyoriginalguideforsome(slightlyoutdated)tipsonhowtodothis.Seealsothechapterbelowformoredetailsonhowtheconfigurationtagandeventtagsinteract. WithintheGA4Eventtagtype,youhavesomefieldsandsettingsyoucanconfigurethetagwith. Setting Description ConfigurationTag Ifyouwanttouseaconfigurationtag,youcanselectithere.Alternatively,youcanignoretheconfigurationtagandjustsetameasurementIDmanually. EventName ThenameoftheeventaswillbeshowninGA4reports.Therecommendedformatissnake_case.Trytoavoidusingthesamenamesasautomaticallycollectedeventsunlessyouknowwhatyou’redoing. EventParameters AddanyparametersyouwanttosendwiththeeventtoGA4.Ifyouuseaconfigurationtag,thenanyparameterssetinthatwillalsobeappliedtothishit(withthevaluesfixedtowhattheywerewhentheconfigtagwasfired).Rememberthatifyouwanttouseparametersinreports,youneedtoregisterthemascustomdimensions. UserProperties Addanyuserpropertiesyouwanttosetwiththisevent.Userpropertiesaresimilartouser-scopedcustomdimensionsinUniversalAnalytics:theyapplytoallfuturehitsfromthisuser,untilanewvalueissetforeach.YoudoneedtoregistertheminGA4forthemtobeavailableinreports. Onceyou’veconfiguredtheeventnameandtheparameterstoyourliking,allyouneedtodoisaddatriggertothetagandstartcollectingthedata. Ifyou’reusingGoogleTagManager’sPreviewmodetotestyourtagwith(asyoushould),thehitwillautomaticallyhavethe_dbgparameterset,andyou’llseeitinDebugView. Quotasandlimits Unfortunately,GA4eventshavesomearbitrary,andfranklyveryannoying,quotasandlimitsthatyouneedtobeawareof.Seethisarticleforthefulllist. Forexample,youshouldavoidcollectingmorethan500uniqueeventnamesinGA4.Eventhoughthislimitdoesn’tseemtobetechnicallyenforced(youcancollect500+uniqueevents),you’restillinviolationofacollectionlimit,andGooglecanstartenforcingthislimitatanytime. Similarly,whileyoucancollectmorethan25parametersinasingleeventtag,only25wouldbepassedontoreporting. Notethatevenifyougooverthequotasineventparametersandcustomdimensions,theywillstillbepassedthroughtotheBigQueryexport,whichmakestheBigQueryexportasupervaluablethingtosetupineverysingleGA4implementation! Thesequotasandlimitswillmostlikelychangeastheplatformmatures,soIrecommendkeepingthedocumentationbookmarkedsothatyouaren’tblindsidedbychangesthatcouldimpactyourdataquality. Enhancedmeasurement Enhancedmeasurementisreallyneat.Ittakesaleafoutofautotrack.js’book,andwithafewflavorsfromGoogleTagManager’striggers,andbakesitallintoasimple,automatedtrackingtoolorchestratedbygtag.jsitself. Confused?Sorryaboutthat.Inshort,enhancedmeasurementtracksstuffautomaticallyjustbyaddingtheconfigurationtagtothepage. EnhancedmeasurementiscontrolledfromtheGA4adminsettings. Ifyouenableenhancedmeasurement,thefollowingeventswillbetrackedautomatically(assumingyoudon’tdisablethem)-seetheofficialdocumentationformoredetails. page_view-sentwiththepageloadaswellasbrowserhistoryeventswithsingle-pageapps. scroll-sentwhentheuserscrollstothebottomofthepage. click-sentwhentheuserclicksanoutboundlink. view_search_results-sentwhentheuserloadsapagewithaconfiguredsearchqueryparameter. video_start,video_progress,video_complete-sentautomaticallywhentheuserstartstoviewavideo,progressespastpredefinedpercentagesofthetotalvideolength,andreachestheendofthevideo. file_download-sentwhentheuserclicksalinktoafilewithoneofthepredefinedextensions. Notethatastheseare,forallintentsandpurposes,automaticallycollectedevents,youcan’tchangeormodifytheparameterssentwiththesehits.Youcanaddparameterstothembysettingthemgloballyinaconfigurationtag,butcheckoutthislaterchapterforsomeseriouscaveatstosettingeventparametersinaconfigurationtag! Youcanalwaysopt-outofenhancedmeasurementtrackingbymodifyingtheGA4datastreamsettings.Forexample,I’mnotahugefanofthescrollevent,soIneverenableit-I’dratherhavefullcontroloversomethingaspotentiallyspammyasscrolltracking. BigQueryexportandGA4events Ifyou’vebeenreadingmyblog,youmighthavenoticedthatI’mahugefanofGoogleBigQuery. OneofthemainreasonstostopreadingthisrightnowandgoandimplementGA4isbecauseitcomeswithafreeBigQueryexportofallyourGA4data! BigQueryitselfhas,naturally,costsassociatedwithusage,butyoudon’thavetopayGoogleAnalyticsfortheprivilegeofaccessingrawdataintheexport. Forthepurposesofeventtracking,theBigQueryexporthasahuge,hugebenefit. QuotasthatwouldapplytoeventsinreportsdonotapplytothedataexportedtoBigQuery! Inotherwords,ifyou’vereachedthemaximumnumberofcustomdimensions,forexample,allthecustomparametersthatyousendtoGA4willstillbeexportedintoBigQuery. Thismeansthatyoumightendupwithtwodifferentapproachestothedatacollectedbyasingleplatform. Firstisthedatathat’ssurfacedinthereportingUI.Thisisyoureverydaydata-subjecttoquotasandlimitations,buteasytomanipulateandexploreforusefulinsights. ThesecondistherawdatainBigQuery.Thisisthedatasetthatyoucantake,sculpt,engineer,extract,andmanipulatehoweveryouwish.ItletsyoubreakfreeoftheprescriptiveschemaimposedbyGA4,andyoucanstarttotrulyunravelthewondersoftheeventstreammodel. Ifyou’recuriousabouthowBigQueryandGA4playballtogether,takesalookatthisarticlethatPawelKapuscinskiandIwrote! Eventtypes ConsideringthatGA4isbasicallyaneventstreammodel,it’snotsurprisingthateventsthemselvesarecategorizedinanumberofdifferentways. Therearetheautomaticallycollectedevents,whichGA4,onewayortheother,collectswithoutneedingmanualtagging. Thenthereareabunchofrecommendedevents,whichGooglestronglyrecommendsyoutouse(iftheyareapplicableforyourmeasurementneeds). Finally,iftherearenoautomaticallycollectedeventsorrecommendedeventsthatsuityourusecase,youcanalwaysusecustomevents. Automaticallycollectedevents Automaticallycollectedeventsareenumeratedinthisdocument.Bothapp(FirebaseSDK)andweb(GlobalSiteTag/GoogleTagManager)automaticallycollectsomeevents,andifyou’veenabledenhancedmeasurementforthewebstream,evenmoreeventsarecollectedwithouttheneedtomanuallytagthesite. Justtoreiterate-aneventisanautomaticallycollectedeventwhenitdoesn’trequireaddingamanualtagorcodesnippetforthedatacollection.Someautomaticallycollectedeventscollectadditionalparametersthathelpfleshouttheeventmetadata. Herearetheautomaticallycollectedeventsfortheweb: Eventname Description Trigger click Outboundlinkcollection(whenenabledviaenhancedmeasurement). Clickonalinkthatleadsoutofthecurrentdomain. file_download Filedownloadtracking(whenenabledviaenhancedmeasurement). Clickonalinkthatdownloadsafilewithoneofthepredefinedextensions. first_visit Firstvisitfromagivenclient/userID. WhenaneventiscollectedfromanewclientoruserID. page_view Whenapageisloadedorabrowserhistoryeventhappens(whenenabledviaenhancedmeasurement). Pageloadorhistoryevent(pushState,replaceState,popstate). scroll Scrolltracking(whenenabledviaenhancedmeasurement). Scrolltothebottomofthepage. session_start Aneventstartsanewsession. 30minuteshaveexpiredsincethelasteventsentbythecurrentuser. user_engagement Thesessionisconsideredanengagedsession. Activeengagementwiththewebsiteformorethan10seconds,oraconversioneventcollected,ortwoormorepageviewscollected. video_complete YouTubevideowaswatchedtocompletion(whenenabledviaenhancedmeasurement). Videoends. video_progress YouTubevideoiswatchedpastspecificprogressmilestones(whenenabledviaenhancedmeasurement). Videoprogressespast10%,25%,50%,and75%. video_start YouTubevideowatchingbegins(whenenabledviaenhancedmeasurement). Videostarts. view_search_results Asearchresultspageisviewed(whenenabledviaenhancedmeasurement). ApageisloadedwithsearchqueryparametersintheURL. Asyoucansee,manyoftheeventslistedhavetodowithenhancedmeasurement.However,therearesomekeyeventsthatarealwayscollected,andinterestinglytheymightnotactuallyhavetheirownhittypesatall.Instead,theyarederivedfromothereventsthatarecollectedonthesite. Forexample,let’ssayyoucollectapage_vieweventfromauserwhohasn’tvisitedyoursitebefore,andthispage_viewisthefirsthittheysend.Thisiswhatyou’llseeintherequest: The_fvparameterdenotesthatthisisafirstvisitevent(theuserisanewuser),andthe_ssparametermeansthatthiseventstartedanewsession.WhenyoulookatthedatainGA4,thisonesinglepage_vieweventactuallysplitsintothreeseparateGA4events! Ifyoulookattherequestagain,you’llseethatthesegparameterhasthevalue0.Thismeansthatthesessionisnotconsideredengaged.Whentheuserthensendsanotherpageviewbeforethesessiontimeout(30minutes),thisiswhattheparametervaluebecomesinthenewpageviewevent: Ontheweb,user_engagementiscollectedinmilliseconds,witheacheventthatclassifiesasanengagementeventsendingthecurrentengagedtimewiththe_etparameter.Thisparametervalueisn’tsurfacedinGA4events,butitisavailableinBigQuery: Foraplatformthatcelebratesnotbeingboundtoanarbitraryconceptofasession,itsuredoesseemlikeithasn’tshruggedoffthisarbitrarinessentirely.Timewilltellhowtheseeventswillproperlytranslatetothereports. Havingsaidthat,theideathatasessionisjustanannotation(the_ssparameterandthededicatedevents)ratherthanakeyaggregation(asinUniversalAnalytics)isinspiring.It’smucheasiertoreconstructyourownconceptofwhatameaningfulaggregationmetricis. SeethisarticlebyJulesStuifbergenforanexampleofhowyoucanbuildyourownsessionapproachusingBigQueryandtherawdataexportfromGA4. Recommendedevents Recommendedeventsareacuriosity,mainlybecauseatthetimeofwritingtheyhaveverylittlefunctionaluseinGA4. Googlehasabunchofsupportpagesfocusedontellingyouwhatsemanticstousewhencollectingeventsforspecificsegmentsandindustries. Forexample,whentheuserlogsin,Googleinstructsyoutouseaneventwiththenameloginandaparameterwiththenamemethod. Why?Whoknows.There’snobenefitinthecurrenteventstocollectinganeventwiththenameloginasopposedto,forexample,user_login.However,it’sarecommendedevent,soithastocarrysomeweight,right? Well,again,timewilltell.I’massumingsomeoftheseeventsgetcollectedintotheirowndedicatedreports.Hopefully,somewillevenbeexemptfromcurrentquotas,ecommerceeventsinparticular. Infact,ecommerceeventsareanexceptiontotherantabove-theydohavefunctionalweightastheypopulatethemonetizationreports.TakealookatmyguideforecommerceimplementationinGA4formoreinformation. Fornow,ifyouwanttoaddanewdatacollectiontagtothesite,takealookatthelistofrecommendedeventsandseeifyoufindonethatfitsyourusecase.Ifyoudo,usethat,andtrytousetherecommendedparametersaswell.There’snoharmindoingso,andatbestyou’llenablesomecoolfunctionalitythatGooglewillreleaseinthenearfuture. However,ifyoudon’tfindarecommendedeventthatfitsyourusecaseperfectly,don’twastetimetryingtoshoehornasquarepieceintoaroundhole.Usecustomeventsinstead. Customevents Onceyou’veexhaustedthelistofautomaticallycollectedandrecommendedevents,andyoucan’tfindonethatfitsyourtrackingneed,youcanalwayssendwhatevereventnameyouwish.Justnotethattherearesomereservednames. Customeventsaresuperpowerful,evenifGoogleisoddlydiminutiveabouttheiruse. Forsomereason,Googlereallywantsyoutouseanythingbutcustomevents.Idon’treallyagreewiththis.CustomeventsareyourchancetochoosehowGA4willserveyourorganization.Evenifthedataisn’tsurfacedinmostofthestandardreports(oddargumentbecausecustomeventsarecertainlyavailableinallthekeypartsofthereportingUI),theywillbeavailableinBigQuery. Nomatterhowlongthey’vebeeninthegame,Idon’tthinkGooglecanorshouldprescribehowyouaretodoeventtrackingonanygivenwebsite.Thus,taketheirrecommendedeventswithagrainofsalt,especiallysincetheyhavelittlefunctionalimpacttoday,andusecustomeventsatyourleisure. FamiliarizeyourselfwithBigQuery-itreallyisthekeytomakingthemostofGA4.Ilovetheanalysishub,andI’msureI’llusethedataAPIreligiouslyonceithasastablerelease,butnothing-nothing-willreplaceBigQueryasmyanalysistoolofchoice. Eventparameters Asmentionedabove,eventscompriseaneventnameandparameters. Parametersarefurthersplitintospecialparameters(reservednamesthatcontaintechnicaldetailsaboutthehit),customparameters(textandnumberparameters),anduserproperties. Specialparameters Theseparametersarecollectedwitheverysingleevent,regardlessofifit’scollectedautomaticallyortaggedmanually: ulorlanguage,whichcollectsthebrowserlanguage(e.g.en-us). dlorpage_location,whichcollectsthecurrentURL. drorpage_referrer,whichcollectsthereferrerURL(oremptystringifnotavailable). dtorpage_title,whichcollectsthepagetitle. srorscreen_resolution,whichcollectsthescreenresolution. Thereareadditional“special”parametersthatarecollectedinsomecases.Theseinclude(butarenotlimitedto): cid-ClientID;thecookieidentifierthathelpsGA4recognizerepeatvisitsfromthesamedevice. uid-UserID;anidentifieryoucansetmanuallybasedonanauthenticationtoken,forexample.Thishelpsyouunitecross-platformandcross-devicebrowsingunderasingleloginidentifier. sid-SessionID. sct-Sessioncount;howmanysessionshavebeencollectedfromthecurrentuser.NOTE!Asthisiscollectedwithaclient-sidecookiethatisnotrelatedtotheClientIDcookie,it’spossiblethisnumberdoesn’tactuallyreflectreality,andaBigQueryanalysismightreturndifferentresults,forexample. seg-Sessionengaged;ifthecurrentsessionisconsidered“engaged”. _fv-Firstvisit;ifthecurrenthitisthefirsthitcollectedfromthisuser. _ss-Sessionstart;ifthecurrenthitstartedanewsession. Customparameters Youcansetcustomparametersbyaddingthemmanuallytoyourtags.Automaticallycollectedeventscancollectsomecustomparametersautomaticallyaswell. Customparameterscomeintwoflavors: Textparameters,whenthevaluesettothisparameterisnotanumber(ep.prefixinthehit). Numberparameters,whenthevaluesettothisparameterisanumber(epn.prefixinthehit). Themaindifferenceisthattextparameterscanbeusedascustomdimensionsandnumberparameterscanbeusedascustommetrics. Tosetparameters,youaddthemintotheeventtaglikethis: HereI’veconfiguredthetwovariables({{Readability-Getmediangrade}}and{{Readability-Getreadingtime}})toreturnnumbers,sotheygetautomaticallyconvertedtonumberparameters.Theuser_leveliscastintoastringbyGoogleTagManager(asit’shard-codedintothetagfield),andthusit’streatedasatextparameter. Theonlycaveattosettingeventparametersinthetagisthateventparameternamescannotbeginwithgoogle_,ga_,orfirebase_. Whenyouwanttouseeventparametersforanalysis,theyneedtoberegisteredascustomdimensionsandmetricsfirst. IfyouhavetheBigQueryexportenabled,alleventparameterswillbeexportedtoBQwhetherthey’reregisteredascustomdimensions/metricsornot. Userproperties Userpropertiescanbesetwitheventsaswell.AuserpropertyactssimilarlytoUniversalAnalytics’user-scopedcustomdimensions,withthemaindifferencethattheyapplyfromthehittheyweresetonwardsratherthanthesession*theyweresetasinUniversalAnalytics. UserpropertiesneedtoberegisteredintheGA4userinterfaceforthemtobeavailableinreports. Tosetauserproperty,simplyaddittothetaginthecorrectplace: You’llseethatit’sincludedinthehitwiththeup.prefix. Therearesomeuserpropertynamesthatcannotbeusedastheyarereserved.Checkthelisthere. Configurationtagandevents WhenyoucreateaneventtaginGoogleTagManager,youhavetheoptionofchoosingaconfigurationtagtosetthingsupfortheeventhit. Theconfigurationtagis,surprisesurprise,thesameastheconfigcommandwiththeglobalsitetag(gtag.js). Youcanuseittoestablishasharedconfigurationforyoureventhits,andyoucanevenuseittosetpersistenteventparameters. ThemostcommonusecasefortheconfigurationtagisforconfiguringtheGA4implementation.Youcanaddfieldsthatconfigurehowcookiesaresetortowhichendpointtosendthehits(usefulifyouwanttocollectthedatawithaservercontainer). However,youcanalsosetpersistenteventsanduserpropertieswiththeconfigurationtagaswell.Anyfieldnamesthatyousetthatarenotreserved(e.g.cookie_domain)willbetreatedaseventparameters,andtheywillbeincludedwitheverysingleeventthatusesthisconfigurationtag. Notethatthere’sonepotentiallyprettydevastatingcaveatwithsettingpersistenteventparametersanduserpropertieswiththeconfigurationtag: ThevalueswillbefixedtotheirinitialvaluesandwillNOTbeupdatedwitheveryevent. Inotherwords,whenyousetaneventparameterorpropertyintheconfigurationtag,itwillbesentwitheverysingleeventthatusestheconfigurationtag.However,thevaluewillalwaysbewhateveritwaswhentheconfigurationtagfired. It’sthusnotausefulwaytosetdynamicvalueslikeeventtimestampsorsimilar.Instead,itshouldbeusedtosetparametersthatareunlikelytochangefromoneeventtothenext. Ecommerceevents Ecommerceeventsare,atthetimeofwriting,partofaveryspecialanduniquecast:theyarerecommendedeventsthatactuallydosomething. Thetypicalstructureofanecommerceeventisaprescribedeventname(e.g.add_to_cart)togetherwithanitemsarraythatreflectstheitemsorproductsthatwereinvolvedintheaction. Ifyouwanttostarttaggingyoursiteforecommercedatacollection,I’dliketodirectyoutomycomprehensiveimplementationguideforGA4ecommerce. Onecuriosityaboutecommerceeventsisthattheitemsstructureisanactualarray.Typically,eventparametersareprimitivevaluessuchasstringsornumbers. Theitemsarrayisarefreshingchangeandhopefully,hopefully,asignthatGA4willstartopeninguptherigiddatastructureinheritedfromUniversalAnalytics,wheretheonlymulti-dimensionalvaluesyoucancollectareecommerceobjects. Imean,thatsyntaxofturningthearrayofobjectsintothisweird,proprietarystringformatdoesn’tmakeverymuchsenseeither,butatleastyoucansendsomethingotherthanjustprimitivevaluestoGA4. Ireallyhopethey’llextendthedatamodeltoacceptJSONvalues,forexample.BeingabletosendanarrayorobjectasaneventparameterandthenhavingitbeautomaticallyparsedforthereportingUI(andnestedforBigQuery)wouldbeanabsolutelyincrediblefeaturetohaveinGA4.Somethingthat’sbeenmissingfromGoogle’sanalyticstoolssincedayone. Debuggingevents Fordebuggingtheeventimplementation,therearethreetoolsIuse. ThenewTagAssistantpreviewmodeformakingsurethattheeventfieldsarepopulatedcorrectly. Thewebbrowser’sdevelopertoolsformakingsurethehitpayloadcontainsallthecorrectvalues. GA4’sDebugViewformakingsurethedataendsupinGA4inthecorrectformat. Ifyou’reafanofbrowserextensions,IrecommendDavidVallejo’sexcellentGTM/GADebugwhichcomesequippedwithfullGA4debuggingsupport! TagAssistantPreview Whenyou’redebuggingyourGA4setupwithTagAssistant,youhavetwowaysofvalidatingyoursetup. First,youcandebugtheGTMcontainerwhereyou’veimplementedtheGA4tags.Choosethetriggerevent(e.g.DOMReady),andmakesureallthefieldsintheeventtaglookright. YoucanalsoselecttheGA4measurementIDtoseeifthehitactuallydispatched. Notehowthepage_vieweventnameistranslatedtoPageViewintheTagAssistantview.Unfortunately,thedebugexperienceforaGA4trackerisstillabitunwieldy,andyoujusthavetoknowwhateventnamestolookfor.Luckilyit’susuallyeasytoclickthroughthehandfulofavailablemessagestofindtheonewhereyourhitwassent. WhendebuggingwithTagAssistant,yourfocusshouldbeonverifyingthatallthefieldsandparametersresolvetotheircorrectvalues.Ifsomethingisoff,youknowitneedstobefixedinGTM. Developertools EventhoughthenewGA4measurementIDdebugviewshowsyouthehitwasdispatchedwithcertainvalues,Istillliketodonetworkrequestdebuggingusingthebrowser’sdevelopertools. InGA4,therequestissenttoa/collectendpointjustaswithUniversalAnalytics.However,you’llbeabletoidentifyaGA4payloadbythev=2parameteraswellastheGA4measurementIDsentwiththetidparameter. Checktherequests,makesuretheyreturna204statuscode. GA4requestsreturna204statusbecausethecontenttypeforGA4requestsistext,buttheresponseisalwaysempty.It’sstillasuccessfulrequest! Thengothroughtheparametersandmakesureallthevalueslookgood.ThisiswhattheactualrequesttoGA4willbe,soifsomethingisoffatthispointyou’llknowyouneedtofixitatitssource(e.g.GTM). DebugView Finally,ifyou’repreviewingaGoogleTagManagercontainer,thehitwillbeautomaticallysenttoGA4’sDebugView.IfyouwanttomanuallyenableDebugViewforotherhits(e.g.whennotpreviewingacontainer),youcanalwayssetthedebug_modefieldtoanyvalue(thoughtrueprobablymakesmostsemanticsense). Whentherequestincludesthedebugmodeparameter(_dbg),you’llfindareal-timedatastreamofsimilarhitsintheDebugViewreportinGA4. Ican’temphasizeenoughhowstupendouslyamazingthisfeatureis.Tobehonest,it’smyfavoritepartofGA4’sreportinginterface! Areal-timestreamofdebugevents,withalltheparametersavailableforperusal,andyoucanevenseehowsomeautomaticallycollectedeventsaregeneratedonthefly! So,asthelaststepofdebuggingyoureventimplementation,makesureDebugViewagreeswithwhatyouthinktheeventshouldlooklike.Ifeverythinglooksgood,thenextstepistolocatethedatainyourstandardreports(mighttakesometimetoreachthose). IfsomethinglooksoffinDebugView,theissuemightbeatthesource(somethingwaswrongwithGTMafterall),oryoucouldhavemessedsomethingwithGA4’sdatastreamsettings. Debuggingisanacquiredskill-it’snoteasytodobecauseyouneedtoknowwhatyou’relookingforbeforeyoucanflagitasapotentialissue.However,whatmattersisconsistencyandthedisciplinetoapproachdebuggingwithanend-to-endprocessratherthanjustcherry-pickingindividualpartsoftheeventimplementationforanalysis. Itdoesn’tmakesensetoonlylookatyourGTMsetupiftheissuecanalsobeinyourGA4settingsorviceversa. Summary Ihopethisguidehasbeenuseful!SettingupeventtrackingwithGA4canbedifficultatfirstbecausethere’salotofbaggageinheritedfromUniversalAnalytics. IwanttosharesomethingthatI’vementionednumeroustimesintrainingsanddiscussionswhenGA4comesup: Idon’twantGA4torepeatUniversalAnalytics’mistakes! SomanypeopleareholdingoffwithtryingGA4outbecausetheywantittohaveeverythingthatUniversalAnalyticshadfirst.What’sthepoint?UniversalAnalytics’datamodelwasfarfromperfect.Sessions,sampling,limitedcustomdimensions,views,filters,clientIDs,justtonameafew. IreallyhopethatGA4findsawayoutoftheshacklesimposeduponitbyvirtueofbeingananalyticsplatformcreatedbythesamecompanythatalsocreatedGoogleAnalytics. GA4’sdatamodelisstrictlyevent-driven,eveniftherearewhiffsofsessionsandusershereandthere.Thehit-streamvibesarestrongwiththisone,whichmightmakeitdifficulttoadjustaftertheawkwardhierarchicaleventmodelofUniversalAnalytics. Withthisguide,mypurposehasbeentoshowhowyoucanapproachimplementingeventtrackingwithGoogleAnalytics4.RememberthatGA4isstillinitsinfancy-there’slikelytobelotsandlotsoffeaturereleasesbetweennowandsoon.You’llbedisappointedbysomeandelatedbyothers,butonething’sforcertain:it’sabravenewworldforGoogle’sanalyticstools.Iftheydon’tcomewithgunsblazingoutofthegate,theyrisklosingfootholdinaworldwhereviableanalyticsplatformsareadimeadozen. I’mexcitedattheprospectsofallthethingsyoucandowithGA4’seventstreammodel,butI’malsoabitworriedabouthowstrongthepullofUniversalAnalyticswillbe. WhatdoyouthinkaboutGA4’seventtrackingcapabilities?Or,ifyouwish,feelfreetounloadyourthoughtsonGA4ingeneral. TAGGEDIN googletagmanager GA4 googleanalytics4 events NEXT PREVIOUS NEXT PREVIOUS ShareonFacebook ShareonTwitter ShareonLinkedIn SimoAhava Husband|Father|Analyticsdevelopersimo(at)simoahava.com SeniorDataAdvocateatReaktor Finland



請為這篇文章評分?