Track Events with Google Analytics 4 (GA4) and Google Tag ...

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

In this guide, you will learn how to track events with Google Analytics 4 and Google Tag Manager. Also, you can watch a video tutorial. Search January1,2022 HowtoTrackEventswithGoogleAnalytics4andGoogleTagManager Updated: January1st,2022 WhenGoogleAnalytics4wasintroduced,itwasannouncedastheevent-basedanalyticstoolwhereeverythingisanevent.Apageview,apurchase,etc. Andtherearemanythingstoknowaboutthemthateventuallymaterializedintothisblogpostandavideotutorial. Today,IwillshowhowtotrackeventswithGoogleAnalytics4andGoogleTagManager. Sure,Icouldwriteacouplemoreparagraphsinthisintroductiontohookyouupandintrigueyou,butIwillbehonest.Thisarticleisabehemoth.Itincludesmanyvaluablethingsandtipsthatarealmost8000-words-long.Andeveryartificiallyinsertedparagraphwouldjustsimplybedisrespectful.   Also,keepinmindthatthisguidefocusesmainlyonthesetup.Iwillincludeachapterwithaquickoverviewofreportswhereyouwillseetheeventdata(includingcustomevents)butthat’saboutit.   TableofContents +Showtableofcontents+ Videotutorial UpgradingtoGoogleAnalytics4 ChangescomparedtoUniversalAnalytics(GA3) 4categoriesofeventsinGoogleAnalytics4 #1.Automaticallycapturedevents #2.EventstrackedviaEnhancedMeasurement #3.Recommendedevents #3.1.ExampleofaRecommendedEvent:logintracking #4.Customevents #4.1.ExampleofaCustomEvent:MenuLinkClickTracking #4.2.Registercustomdefinitions Createnewevents(intheGA4interface) ModifyEvents(intheGA4interface) Testyoureventsinreal-timereportsandDebugViewinGoogleAnalytics4 WherecanIfindtheeventsdatainGoogleAnalytics4reports? “Reports→Engagement →Events”report Explorationreports Howtoplanyoureventnamingconventionandstructure Eventlimits UsefulresourcesabouteventtrackinginGoogleAnalytics4 FinalWords   Videotutorial Ifyouprefervideocontent,here’satutorialonmyYoutubechannel(*cough*considersubscribing*cough*).However,theblogpostismorein-depth.Soifyouwanttolearntheinsandoutsofthistopic,it’srecommendedtoconsumebothformatsofthecontent.   UpgradingtoGoogleAnalytics4 Beforewecontinue,Ihavealsocreatedablogpost andaYoutubevideoaboutupgradingtoGoogleAnalytics4.Ifyouarereadingthisblogpostin2020and2021,thenyoushouldtakealookhereaswell. Inthattutorialandvideo,Iexplainthingslike: Shouldyouupgradenow ShouldyouuseJUSTGoogleAnalytics4(andgetridofthepreviousversion) HowtoupgradetoGA4 Butifyouarereadingthistutorialin2022orevenlater,thenyoudon’tworryaboutupgradingtoGA4(becauseit,mostlikely,beyourmainWebTrackingplatform).   ChangescomparedtoUniversalAnalytics(GA3) Note: ifyoudon’tcareaboutUnivreersalAnalytics,skiptothischapter. ComparedtoUniversalAnalytics,a.k.a.UA(thepreviousGoogleAnalyticsversion),thedatamodelinGoogleAnalytics4ismuchmoreflexible.Thismeansthattherearefewerrestrictionsandrequiredfields/parameterscomparedtotheUA. Themostnotabledifferenceregardingeventsis4parametersthatyoucouldsendtogetherwitheveryeventtoUniversalAnalytics(excludingcustomdimensions): EventCategory(required) EventAction(required) EventLabel(optional) EventValue(optional) AndwhenyouopentheUniversalAnalyticseventreports,you’dfirstseetheEventCategory.Thenyoucanclickitanddrilldowndeeper(toseeactionandthenlabel). InGoogleAnalytics4,thenamingconventionismuchmoreflexibleanditsolelydependsonthepersonwhoisimplementingthetrackingsetup. InGA4,thereisaparametercalledEventName,andtheneverythingelsedependsonwhatyouhaveplanned.Ifyouwish,youcansendnoadditionalparameters.Oryoucansend4additionalparametersthatbetterdescribethecontextofthatevent.Forexample,let’ssaythatsomeonefilledinthe“Requestdemo”formonyourwebsite.Youcouldsendthefollowingevent: Eventname:request_demo product_name: amazingproduct company_size: 99-250 company_industry:internetandtelecom annual_revenue:50-100M Thelast4itemsinthelistabovearecustomparametersthatyoucansendtogetherwithanevent.However,keepinmindthattherearesomelimits regardingthenumberofcustomparametersthatyoucansendwithasingleevent.Iwillmentionthemadditionallylaterintheblogpost. Whileyoucancomeupwithanyeventsyouwant,therearesomerecommendationsthatyoushouldfollow.Butfirst,let’stakealookat4categoriesofeventsinGA4. Ifyouarenotsurehowtoname/structureyourevents,Iwillgiveyouhintslaterinthisblogpost+aspreadsheettemplate.Butfirst,let’slearnaboutvarioustypes/categoriesofeventsinGoogleAnalytics4andhowyoucancreate/modifythem.Ibelievethatit’simportanttohaveagoodunderstandingofeventsinGA4beforewestartthinkingaboutthestructure.   4categoriesofeventsinGoogleAnalytics4 InGA4,eventscanbesplitinto4categories: Automaticallycollectedevents EnhancedMeasurementevents Recommendedevents Customevents Theprocessofhowyoushouldplanthestructureofyourevents(namesandparameters)isbydoingthefollowing: Checkiftheeventthatyouwanttotrackisamongtheautomaticallycollectedevents Ifnot,thencheckifyoureventismentionedamongtheEnhancedMeasurementevents(e.g.scrollorfile_download) Ifnot,thenchecktherecommendedeventsandtheirnamingconvention Ifnoneoftheabovecategoriesapplytoyourevents,createacustomeventwithaneventthatyouwant Intheupcomingchaptersofthisblogpost,Iwillexplainwheretolookandhowtofindthecategoryofyourevent.Andonceyougetmorefamiliarwithevents(andhowtoconfigurethem),Iwillsharesometips(andasamplespreadsheet)thatcanhelpyouthinkaboutthestructureofyoureventsandanamingconvention.   #1.Automaticallycapturedevents SinceIammostlyfocusingonwebtracking,thesameprinciplewillapplytothisguide.TherearecertaineventsthatGA4tracksautomatically.Youcanfindafulllisthere.Onthatlist,youwillfindbothappandwebevents.Infact,thelistofwebeventsisabitlongerthanI’dexpect.EnhancedMeasurementeventsarealsolistedthere. Fornow,let’stemporarilyignorethemandfocusonlyonthoseeventsthatareautomaticallycapturedandshouldnotbeaddedtoanyothereventcategory.Thelistofwebsiteeventsgoeslikethis: first_visit.Thisis thefirsttimeauservisitsawebsiteorlaunchesanapp. session_start.Whenauserengagestheapporwebsiteandstartsanewsession user_engagement.Thiseventisfired10secondsafterthevisitorhasstayedonapage.Butitalsomightperiodicallyfirewhiletheappisintheforeground.Youcanlearnmorehere. Ididn’tmentionthepage_viewherebecauseIaddedittothe EnhancedMeasurementsection.And,onceagain,ifyouwanttoseetheappevents,youcancheckthemhere.   #2.EventstrackedviaEnhancedMeasurement WhenyouconfigureawebdatastreaminGoogleAnalytics4,youhaveanoptiontouseEnhancedMeasurement.ItisdesignedtohelpmarketersgetasmanyeventsinthereportsaspossiblewithouttheneedtocooperatewithdevelopersorconfigureinGoogleTagManager. IfyougotoAdmin>DataStreams>Selectthewebdatastream,thefollowingwindowwillopenwhereyouwillseeasectioncalled EnhancedMeasurement. Bydefault,thisfeatureisenabledandwillautomaticallytrackthefollowingevents: Pageview(eventname:page_view) Scroll(eventname:scroll) Outboundlinkclick(eventname:clickwiththeparameter outbound:true) Sitesearch(eventname:view_search_results) VideoEngagement(events: video_start,video_progress,video_complete) FileDownload(eventname: file_download) Ifyouwant,youcandisable/enableeventsindividuallyandyoucandothatbyclickingthegeariconinthe EnhancedMeasurement sectionandthenclickingtogglebuttons. Also,someeventscanbecustomizedadditionally.Let’stakeaquicklookateacheventandtheirrespectivesettings. page_view. ThiseventissenttoGA4whenanewpageloadsortheURLofthepagechangeswithoutreloadingthepage(a.k.a.historychangeevents) scroll.ThiseventissenttoGA4onceperpagewhen avisitorscrollsbelowthe90%thresholdofthepageheight. click.Thisisaneventfortheoutboundlinkclick(whenaclickedlinkredirectsavisitortoanotherdomain.Togetherwiththisevent,anadditionalparameter outbound(withvalue“true”)issent.Theeventwiththisparametermeansthattherewasanoutboundlinkclick.Togetherwiththisevent,abunchofotherparametersissent: link_classes,link_domain,link_id,link_url. Ifyourbusinessoperatesonseveraldomains,youcangotoTaggingSettings(ofthatverysameeventstream)>Configureyourdomains andthenenterthedomainsofyourbusiness.Allthedomainsthatarelistedtherewillnottriggertheoutboundlinkclickevent. view_search_results. ThiseventwillbesenttoGoogleAnalytics4ifthepageloadsandtheURLofthepagecontainsaqueryparameter,suchas q,s,search,query,keyword.Butifyouwant,youcanincludemoreofthem(upto10). IftheURLofthesearchresultspageishttps://www.yourwebsite.com/search?key=my+search+term,thenyoushouldentertheword“key”(withoutquotationmarksinthesettingsofthesearchevent).IftheURLofthesearchresultscontainsmoreusefulparameters,youcanincludethemaswell. Forexample,iftheURLofyoursearchresultslookslikethis:  https://www.yourwebsite.com/search?key=search+term&results=50,youcouldincludethe“results”(withoutquotationmarks)inthe2ndfieldoftheconfiguration.ThenthisparameterwillbeautomaticallytrackedbyGA4. video_start,video_progress,video_complete.EnhancedMeasurementiscapableoftrackinginteractionsoftheembeddedYoutubevideoonyourwebsiteandthensends“video_…”eventstoGA4.ButthoseembeddedYoutubevideoplayersmustcontainthe?enablejsapi=1parameterintheirURL.Andthatisnotalwaysavailableonwebsites.Also,therearemanyotherreasonswhyYoutubevideotrackingmightnotworkoutofthebox,henceyouwilldefinitelyneedsometweaks. Becauseofthosenuances,I’dsaythatthisautomaticvideotrackingwillnotworkinasmanycasesasyoumightthink,henceI’dpersonallyvouchfordoingthatwithGTM. file_download.ThiseventissenttoGA4whenalinkisclickedandthatlinkcontainsoneofthefollowingfileextensions:.pdf,.xls,.xlsx,.doc,.docx,.txt,.rtf,.csv,.exe,.key,.pps,.ppt,.pptx,.7z,.pkg,.rar,.gz,.zip,.avi,.mov,.mp4,.mpe,.mpeg,.wmv,.mid,.midi,.mp3,.wav,.wma.Inotherwords,ifthelinkopens/downloadsafile.Currently,itisnotpossibletoupdatethelistwithotherextensionsintheGA4interface. Onceyouselectwhicheventsyouwishtotrack,hit SaveinthetoprightcornerandthenmakesurethatEnhancedMeasurementisenabled(thetoggleisblue). Fromthatmoment,yourGoogleAnalytics4willstartautomaticallytrackingtheevents.Seethischapter tolearnhowtocheckifyourdataiscominginproperly.   #3.Recommendedevents AsIhavepreviouslymentionedinthisblogpost,whenyouaretryingtopickthename(andtheparameters)foryourevent,firsttakealookatautomaticallytrackedevents(maybethoseeventsarealreadybeingtracked),thenchecktheEnhancedMeasurementevents.Ifnoneofthoseeventscoveryourcase,takealookatthelistofrecommendedevents.Googlehaspublishedseveralpagesfordifferentvectors: Generic(forallproperties) Onlinesales Games Checkeveryoneofthoselistsandseeifanyoftheeventsmatchyourneed. Forexample,ifyouwanttotrackwhenauserlogsin,thenyouwillfindthe“login”eventinthelistof“Allproperties”. EventhoughGoogleAnalytics4datamodelisveryflexible(andyoucanuseadifferenteventnameforlogin,forexample, logged_in),Googlerecommendsthatyouimplementtheirrecommendeventswhenitmakessensetoyou.ThatshouldhelpGoogleAnalytics’reportsbetterunderstandyourdataandapplyitintheirMachineLearningcapabilities.However,Istilldon’tknowwhatarethosecapabilities(atleastinlate2020). Also,forthemajorityofthoserecommendedevents,Googlealsorecommendssomeparameters.Speakingofthe loginevent,thereisa methodparameter.Ifuserscanlogintoyourwebsitevia email,googlelogin,facebooklogin,etc.,thenitmightmakesensetotrackthemethodaswell.   #3.1.ExampleofaRecommendedEvent:logintracking Let’scontinuewiththeaforementionedloginexample.Let’ssaythatIamworkingonawebsitewherevisitorscanlogin.Iwanttotracktheexactmomentwhenusers/visitorsdosoandwhichloginmethodaretheyusing. IhaveaskedadevelopertoactivatethefollowingdataLayer.push codewhenauserlogsintohis/heraccount. Thevalueofthe loginMethodshouldbereplacedwiththeactualloginmethodthatauserused.Thatisthedeveloper’sjobtowritecustomcodethatreplacesit. WhenadeveloperimplementsthatcodeandIsuccessfullylogin,inGTM’spreviewmode,IshouldseethefollowingDataLayerevent(seethescreenshotbelow).Now,keepinmindthatthiseventaGTM(orDataLayer)event.ItisnotsenttoGA4(oranyotherplatform)yet.Rightnow,itisjustacollectionofdatapointsthatareatourdisposal,meaningthatwecansendthedatafurthertoothertoolslikeGAorFBpixel(oranyotheranalytics/marketingplatformthatweuse). Now,let’screateaDataLayerVariable thatwillaccessthevalueofthe loginMethodandalsoaCustomEventTrigger forthe logineventintheDataLayer. InGoogleTagManager,gotoTriggers>New>CustomEvent,enterthefollowingsettings,andpressSave: ThengotoVariables>User-definedvariables>New>DataLayerVariableandenterthefollowingsettings: Ienteredthe loginMethodbecausethatisexactlywhatadeveloperpushedtotheDataLayer.Ifyourparameter’snameisdifferent,thenenterthatname.Important:variablenamesarecase-sensitive. Afteryoucreateavariableandatrigger,it’stimetocreateaGoogleAnalytics4eventtag.Withit,wewillbeabletosendtheeventdatatoGA4. InGoogleTagManager,gotoTags>New>GoogleAnalytics:GA4Event. Beforeyoudothis,IexpectthatyouarealreadytrackingpageviewsandyoualreadyhaveaGA4configurationtag.Ifyouarenewtoit,readthisguide(thatalsoincludesavideo)tothemigrationguide.Inanutshell,theGA4configurationtagisusuallyresponsibleforcontainingyourGA4MeasurementIDandsomeadditionalconfigurations(ifyouhavethem). So,whenyoucreateanewGA4eventtag,youwillneedto: DefinetheGApropertyID(alsoknownasaMeasurementID) Andtheneventname+parameters Inordertoavoidmanualworkandsettingupallthefields/customizations(suchasGAMeasurementID)ineverytag,youshouldselectyourmainconfigurationtagintheeventtag. IfyouarefamiliarwithUniversalAnalyticsandyouusedtomanagethisinGoogleTagManager,theconceptoftheConfigurationTagisprettyclosetotheGASettingsVariable.Thattagcancontainalotofsettings/configurations.IfyouusethattaginyourotherGA4tags,theywillinheritthechanges. Butatthesametime,youcanstillconfigureadditionalsettingsinyoureventtag.Ifaparticularparameter/fieldisconfiguredinboththeeventtagandintheconfigurationtag,theeventtag’sfieldgetsahigherpriority. Now,let’scontinuetheconfigurationofanevent.Entertheeventname.Sincewearetrackingthelogineventandthename“login”isrecommendedbyGoogle,thisisexactlywhatwearegoingtoenter. Andthenlet’senteranadditionalparameter,theloginmethod.Todothat,expandthe EventParameters section,click AddRow,andthenenter methodinthe ParameterNamefieldandinsertthepreviouslycreatedDataLayerVariableinthe Value field.Youcaninsertthevariablebyclickingthebuttonnexttothatfield. WhydidIenterthe method inthe ParameterName field? BecauseIsawthatinthelistofRecommendedEvents. Whataboutcustomparameters?Whatifyoualsowanttopasstheuser’spricingplanorsomethingelse?Sure,youcandothat.ButIwillexplaincustomparameters/dimensionsinthenextchapter.Allyouneedtoknowrightnowisthatit’scompletelypossibletosendcustomparameterswithrecommendedevents. Now,it’stimetotest.EnablethePreviewmodeinGoogleTagManager,logintoyourwebsiteandcheckifyourGA4EventTagfiredonthatevent.Todothat,youwillneedtoclickonthe logineventinthePreviewmode’sleftsideandthencheckifthetagfired. Ifyouindeedseethatthetaghasfired,that’sagoodstart.Now,youwillneedtogotoGoogleAnalytics4andchecktheDebugView.Youwilllearnmoreaboutthatinthischapteroftheblogpost. Bytheway,ifyouwanttoimplementsales(a.k.a.Ecommercetracking),thenyouwillalsoneedtouserecommendedeventsandfollowGoogle’sstrictrequirements.Learnmorehere.   #4.Customevents Eventually,wehavereachedthelastcategoryofeventsinGoogleAnalytics4.Ifyouwanttosendaneventanditisnotmentionedamongtheautomaticallytrackedevents,EnhancedMeasurement,orRecommendedevents,thenyoucancreatecustomevents. TheconfigurationofCustomeventsisprettymuchidenticaltorecommendedevents.Theonlydifferenceisthatyouwillneedtocomeupwithyourowneventnames. Forexample,ifyouwanttotrackclicksonacalltoactionbutton,thenameoftheeventcanbeanyofthese: call_to_action cta_click cta,etc. Oranythingelse. GA4iscompletelyflexiblehere.However,therearesomelimitationswhenitcomestothemaximumlengthofaneventname. Also,thereisalimitof500uniqueeventnamesperclientID (a.k.a.appinstance,avisitor/user). Update:the“500uniqueeventnames”doesnotapplytowebevents.Learnmore So,speakingofcustomeventtracking,let’slookattheexamplewherewewanttomeasureclicksonmenulinksonawebsite.   #4.1.ExampleofaCustomEventinGA4:MenuLinkClick Note:menulinkclicktrackingtriggerconditionsdifferonmostwebsites(becauseofdifferentclickclasses,IDs,etc.).Trytodoyourbesttoapplythisexample. Onademowebsite,IhaveseveralmenulinksthatIwanttotrack. First,Ineedtocreateatriggerwithcorrectconditionsthatdistinguishanyclickfromamenulinkclick.EnableGoogleTagManager’sPreviewmode andtryclickinganyofthemenulinksonawebsite.Onceyoudothefirstlinkclick,youshouldseethe LinkClickeventinthePreviewmode’sleftsidebar. Ifyoudon’tseeit,youshould: haveatleastoneJustLinksGTMtriggeractivatedonapage orhave“Filedownload”or“Outboundlinks”trackingenabledinyourEnhancedMeasurementSettings Let’ssay,thatyoudon’tuseEnhancedMeasurementinGA4.GotoGoogleTagManager>Triggers>New>JustLinks.Keepthetriggerseton“Alllinkclicks”andsavethetrigger. Bycreatingthistrigger,wewillenablethelink-trackingfunctionalityinGoogleTagManager. ThengotoVariables>Configure(inthe“Built-inVariables”section)andenableallClick-relatedvariables. Refreshthepreviewmode(byclickingthePreviewbuttononceagain). Thengotoyourwebsiteandclickanyofthemenulinks.Actually,clickatleasttwoofthem.Returntothepreviewmodeandyoushouldstartseeing LinkClickeventsinthepreviewmode.Clickthefirst LinkClick eventandgototheVariablestabofthepreviewmode. Thenclickonthesecond LinkClickevent.IamcurrentlylookingforsomevariablethatIcouldusetodistinguishamenulinkclick.Idon’twanttofiremyGA4eventtagonanylinkclick.Iwanttofireitpreciselyonamenulinkclick. Aftertakingacloserlook,IseethatbothlinkscontainthesameClickClassesvalue, site-nav__linksite-nav__link–main.Bytheway, navmeans“navigation”inthiscontext.Great!IwillusethisinmyJustLinkstrigger. GobacktothelistoftriggersinyourGTMcontainerandclickthepreviouslycreatedtriggerforAllLinkClicks.We’lledititandaddacondition:ClickClassescontains site-nav__link–main Savethetrigger.Now,it’stimetocreateaGoogleAnalytics4eventtag.GotoTags>New>GoogleAnalytics:GA4Event.SelectyourexistingGA4Configurationtagandthenentertheeventname.Itsvalueisuptoyou.Anyofthefollowingoptionsareperfectlyfine: menu_click menu menu_item_click menuclick etc. Thesearejustsomeoftheexamples.Sinceweareworkingwithacustomevent,wecannameitwhateverwewant(aslongaswefollowthelimitationsofnamelength,forexample). Inmycase,Iused menu_clickeventname.Butthistime,sendingjusttheeventnameisnotveryuseful.You’dprobablywanttoknowwhichexactmenuitemsareclickedmoreoften.HowaboutwealsosendthenameofthemenuitemandtheURL? Wecoulddothatbysendingadditionaleventparameters.EventhoughyoucoulduseparametersthatarealreadymentionedinthedocumentationoftheEnhancedMeasurement(like link_url and link_text),let’screatetwocustomparameters(becauseIjustwanttoshowyouhowtoconfigurethem). Iamgoingtopasstwoparameters, menu_item_url,and menu_item_name.Imadetheseparameternamesupandyoucandoittoo.That’swhattheflexibilityofthedatamodeloffers. Tosendcustomparameters,youmustexpandtheEventParameterssectionintheGoogleAnalytics4eventtagandthenclickAddRow. Enterthenameofthefirstparameter.Inmycase,thatis menu_item_url.Inthe Valuefield,IwillinsertavariablethatreturnsaclickedURL.Luckily,GTMalreadyofferssuchavariable,it’scalled ClickURL.Clickthe InsertVariable buttonandthenselectthe{{ClickURL}}variable. Let’saddanotherparameter, menu_item_name.Forthatpurpose,GTMoffersanotherbuilt-invariable,{{ClickText}}.Insertitaswell.Sincevisitorsofyourwebsitecantranslateyourpage,{{ClickText}}valuewillalsochange,henceyouwillseeamorediverselistofcollectedvaluesinyourGA4reports. Ifyouwanttosendmoreparameters,youarefreetodothat.Youcansendupto25customparameterswithasingleevent. AssignthepreviouslycreatedJustLinkstriggertothistag.Savethetag.RefreshtheGTMPreviewmodeandclickacoupleofyourmenuitems.GobacktothePreviewmodeandclickthose LinkClick events.CheckiftheGA4eventtagsforMenuLinkClickshavefired. Now,youwillneedtogotoGoogleAnalytics4andchecktheDebugView.Youwilllearnmoreaboutthatinthischapteroftheblogpost.Afteryoutesteverything,hit PUBLISHinthetoprightcorneroftheGTMinterface. IMPORTANT:eventhoughyouwillseeyourcustomparametersinReal-timereportsand DebugViewinGA4,youwillnotbeabletoseetheminotherGA4reports.UnlessyouregisterthoseparametersascustomdimensionsinGoogleAnalytics.Readthenextchapterofthisblogpost.   #4.2.IMPORTANT:Registercustomdefinitions ThisappliestoanyeventparameterthatyousendtoGoogleAnalytics4.Ifyouwanttosee/usetheminthingslikeFunnelexploration,FreeForm,seetheirreportingcardsinstandardreports,etc.,youmustregistercustomparametersintheGAinterface. InGoogleAnalytics4,gotoConfigure>CustomDefinitions.Sincewesent2customparameterswiththemenulinkclick,wemustregisterthembothhere. Clickthe CreateCustomDimensions buttonandthenenter: Thenameoftheparameter.Youcanenterwhateveryouwant.Thisisjusthowthedimensionwillbedisplayedinyourreports.Youcannameit“menu_item_url”,“MenuitemURL”,oranythingelse. Scope.Sincewewanttoapplythisparameteronlytooneevent(andnottoalleventsofthesameuser),weneedtoselect Event Eventparameter.ThisiswhereyouhavetoenteritsnamepreciselyasyouentereditintheGTMtag.Ifyourparameternameis menu_item_url,youmustenterithereexactlylikethat.Don’tworryiftheautocompletefeatureofthatfielddoesnotshowyourparameteryet.Justenteritandsavethedimension Thenregisterasecondparameter(inmycase,thatwas menu_item_name)andsaveit.Bytheway,Isometimesusethewords“customparameter”and“customdimension”interchangeably.Ingeneral,custommetricsandcustomdimensionsarebothgroupedascustomparameters. Andnowwewait.Withinthenext24hours,thecustomparameterswillstartappearinginyourGoogleAnalytics4reports. ====== Sometimes,youmightwant/needtocreate/editeventsdirectlyfromtheGoogleAnalytics4interface.Well,nowyoucan.Readthefollowingtwochapterstolearnmoreaboutthesefeatures.   Createnewevents(intheGA4interface) Theprocessofhowconversions(formerlyknownas goals)arecreatedisdifferentinGA4(comparedtoUniversalAnalytics).It’senoughjusttoclickatogglenexttoaneventintheConfigure>Event list. Butthereisoneproblem.Ifyoutoggletheeventandmarkitasconversion,ALLofthoseeventswillbetreatedasconversions(fromthispointmovingforward).Butwhatifyouwanttohaveonlycertaineventsbemarkedasaconversion. Example:youhavea“Thankyou”pagetowhichusersareredirectedwhentheysubscribetoanewsletter.Let’ssaythattheURLishttps://www.mywebsite.com/thank-you/.IfImark page_vieweventasaconversion,ANYpageviewwillbecomeaconversion.HowcanIseparateonlythosepageviewsthathappenedonthe/thank-you/page? Youcaneithersendadedicatedevent(withadifferentname)fromGoogleTagManager/Gtag.js,oryoucanusethe CreateEventfeatureintheGA4interface. Thisfeatureallowsyoutocreateaneweventbasedonotherincomingevents.Onthe Configure>Events page,click CreateEvent andthenclickCreate. Thenyouwillneedtoenterthenameofthecustomevent.Onceagain,youcannameitwhateveryouwant.Justmakesurethatthenameclearlycommunicateswhatitmeans. thankyou_page_visitmightbeagoodoption. Thenlet’smoveontothe MatchingConditionssection.HerewemusttellGA4whatkindofeventarewelookingfor.Whenthatparticulareventwillbespotted,thenour thankyou_page_visitshouldbecreatedaswell. Inmycase,Ineedtoenterthefollowingconditions: event_nameequalspage_view page_locationcontains/thank-you/ Ifyouwanttocopyalltheparametersfromthe page_vieweventtothenewevent,keepthecheckbox Copyparametersfromthesourceeventenabled. Ifsomeoftheparameter’snameisincorrectandyouwanttofixitaswell,youcan AddModificationinthe ParameterConfigurationsection.Forexample,ifaneventcontainstheparameter pricingPlanbutyouwantittobe pricing_plan, youcanintroduceanewfield(andreuseitsvalue)whileremovingtheincorrectparameter(byleavingthe NewValue empty). Takeacloserlookat[[pricingPlan]]inthescreenshotabove.DoublesquarebracketsmeanthatGA4willreusethevalueoftheparameterpricingPlaninthatevent. Onceyousavethechanges,youwillbeabletoviewthemintheReal-timereportsandtheDebugViewofGA4.Youwilllearnmoreaboutthatinthischapteroftheblogpost. Also,whenyoucreatethatneweventinGA4(andyouwantthattobecomeaconversion),don’tforgettomarkthateventasaconversionintheConfigure>Eventspage. Ifyoudon’tliketowaitforupto24hours(becausethat thankyou_page_visitwillnotappearinthelistofallyoureventsimmediately),youcancreateanewconversionimmediately.ClicktheConfigure sectionontheleftsidebarofyourGA4interface.Thengoto Conversions. ThenclickNewconversioneventandenterthenameoftheeventthatyouhavejustcreated.ClickSave. Thatwayyouwillmarkthenewlycreated thankyou_page_visiteventasaconversion(withouttheneedtowaitfor24hoursuntilitappearsontheConfigure>Eventspage.   ModifyEvents(intheGA4interface) Ifyoudon’twanttocreatenewevents(likeinthepreviouschapter)butinstead,youjustwanttofixatypointheexistingevents,youcanuse the ModifyEventsfeatureintheGoogleAnalytics4interface. Inmy Configure>Events report,Iseetwopage_viewevents. page_view page_view?undefined Ihavenoideawherethatpage_view?undefinedcamefrombutIdon’twanttoseeitinmyreports.Eventhoughthecountofthiseventislow,I’dliketofixit. Icandothatbygoingtothe Configure>Eventsreportandclicking ModifyEvent.  ThenclickCreate. Enterthenameforthefix(thisisforinternaluse) Thenenterthematchingcondition(inmycase,that’s eventname equalspage_view?undefined Andthenentertheneededmodifications(inmycase,that’s event_name and page_view) IfGA4spotsaneventwiththename page_view?undefined, itwillchangeitsnameto page_view. Asyoucansee,theinterfaceandtheflowhereisquitesimilartothe CreateEvent featurethatIhavedescribedinthepreviouschapterofthisblogpost. Onceyousavethechanges,youwillbeabletoviewthemintheReal-timereportsandtheDebugViewofGA4.Youwilllearnmoreaboutthatinthischapteroftheblogpost. Bytheway,keepinmindthatyoucancreateupto50modificationsperpropertyandthatthisfeaturedoesnotapplytohistoricdata.Thismodificationwillapplyonlytonewincomingevents.   TestyoureventsinGoogleAnalytics4 Onceyouconfigureyourevents,it’stimetotestthem.TheprimaryfeaturebuiltfordebuggingGA4dataistheDebugViewsection.YoucanfinditbygoingtoConfigure>DebugViewontheleftsideoftheGA4interface.Clickit. That’stheplacewhereyourdebuggingshouldtaketheplace.DonotmixthiswiththeGTMPreviewandDebugmode.Theyaretwodifferentbeasts. ToenablethedebugmodeinGA4,youhaveseveraloptions(anyofthemwillwork): EnabletheGAdebuggerChromeextension Sendadebug_modeparametertogetherwithanevent HaveenabledGoogleTagManager’sPreviewmodeonapagethatyou’redebugging Inthecaseofthefirstoption,installtheextensionhere,andthenclickitsicon(sothatyoucanseethe ONribbon).Fromthismoment,youwillstartseeingyoureventscomingintotheDebugView. Theotheroptionistosendadebug_modeparameterwitheveryeventthatyouwishtoseeintheDebugView. InGoogleTagManager,youcandothatbyopeningtheGA4Configurationtagandaddingthefollowingparameter: Ifthe debug_mode parameterissettotrue,theeventwillbeseeninDebugView. Ifyouareusingahardcodedgtag.js,herearetheinstructionsonhowtoincludethedebug_modeparameter. ButsinceweareworkingwithGoogleTagManager,havingtheGTMPreviewmodeenabledautomaticallysetsthedebug_modeto true,thusthedatawillstartappearingintheGA4DebugView. WhenyoustartseeingdataintheDebugView,youcanclickoneveryindividualeventandthenalistofparameterswillbedisplayed. ClickonthatparametertoseethevaluethatwasreceivedbyGA4.Nowthatissomegranulardebugging! However,IhavenoticedsomedelaysbetweentheeventactuallyhappeningonawebsiteandthenappearinginDebugView.Sometimes,Ihavetowaitforseveralminutesuntiltheeventscomein.That’sabitunfortunateandhopefully,theteambehindGoogleAnalytics4willimprovethisinthefuture. Also,makesurethatyouhaveselectedthecorrectDebugdeviceinthetopleftcorner. Ifmultiplevisitorshaveenabledthedebugview(e.g.theyallhaveenabledtheChromeextension),youwillseemultipledevicesthereanditmightrequiresometimetofindyourself.Thisespeciallyappliestomyblog,whenmanyofmyreadershaveenabledtheGADebuggerExtensionandIhavetoguesswhichdevice(outoftheother15)ismine🙂 Anyway,onceyoustartseeingdatainDebugView,thingswilllooklikethis. Eventsaremarkedwithblueicons,conversionswithgreen.PleaseignorethefactthatItreat menu_clickeventsasconversions.Thisisjustfordemonstrationpurposes🙂 Ifyouclicktheevent,youwillseetheparametersthatweresenttogetherwithanevent.Clickontheparametertoseeitsvalue. Onceyoumadesurethatthedataiscominginanditisdisplayedproperly,youshouldsubmityourGA4changesintheGTMcontainerandpublishit. YoucandothatbyclickingtheSUBMITbuttoninthetoprightcornerandthencompletealltheotherstepsthattheuserinterfaceasksyoutodo. Afterthat,youshouldsoonstartseeingthenewdatacominginyourreal-timereportsaswell. OntheleftsidebaroftheGoogleAnalytics4interface,gotoRealtime.Thisiswhereyouwillseethedatacomingintoyourreports.Unlikeinthepreviousversion(UniversalAnalytics),thenewreportoffersyoucapabilitiestoseethedataonamuchmoregranularlevel. First,youwillseeamapandabunchofcardswithtrafficsources,mostpopularevents,thenumberofusersinthelast30minutes(bytheway,UniversalAnalyticsreal-timereportshowsthenumberofusersinthelast5minutes). Youcanalsotakealookatthesnapshotofanindividualuser.Youcandothatbyclickingthe Viewusersnapshotbuttoninthetoprightcorner. Then,youwillseeastreamofalleventsofthatparticularuser,youcanclickonthem(justlikeintheDebugView)toseethingsonamoregranularlevel.Ifyouwishtolookatanotheruser/visitor,youcanclickthebuttonhere: Toexitthesnapshot,simplypressthe Exitsnapshot buttoninthetoprightcorner.   WherecanIfindtheeventsdatainGoogleAnalytics4reports? ThisblogpostfocusesmainlyonthesetupofeventtrackinginGoogleAnalytics4.Iwillnotdivedeepintohowtofindinsights,raisequestions,answerquestions,etc.However,IcanshowyouseveralplaceswhereyoucanfindtheeventdatathatyouhavejustsenttoGoogleAnalytics4. Keepinmindthatatthemomentofwritingthisblogpost(late2020),thebuilt-inreportingcapabilitiesofGoogleAnalytics4arestillquitelimited.Hopefully,thatwillchangesoon.Let’stakealookatwhatwehavenow.Herearesomeofthereports: Configure>Events (thiswillshowjustthelistofeventswithcounts.Nothingfancy. Reports>Engagement>Events Explore (a.k.a. Exploration reports) Butthatisnotall.SinceGA4isanevent-basedanalyticsplatform,everyreportisaffectedbyeventsthatyousend(inonewayoranother).Theaforementionedreportsarejustthemostnotableexamples.   “Reports→Engagement →Events”report Thisisanoverviewofalleventsthatweresenttoyourproperty+acoupleofcharts.Belowthem,youwillseealistofeventsandifyouclickonanyofthem,youwilltakeacloserlookatthatevent’sdata.   Explore(a.k.a.Explorationreports,exAnalysisHub) Thisistheplacewhereyouwillbeabletodrilldownintoyourdata.IntheExplorations,youwillbeabletousereportssuchasFreeForm,FunnelExploration,PathExploration,etc. Hereisanexampleofa FreeFormreport.Keepinmindthatyouwillneedtowaitforupto24hoursforthedatatocomeintoyourreports.Soifyoudon’tseethedatanow,bepatient. Let’ssaythatIwanttoseehowdifferentdevicecategoriesareinteractingwiththemenubarofmysite.Remember,Isetupthemenu_clickevent? So,let’sgoto Explore andclickonthe FreeForm block. Theninthe Variablescolumn,Ineedtoincludethemenu_item_urlcustomdimensionbecauseIwanttoseehowmanyclicksdidgeteachmenuURL.ClickthePlusiconandthenfindthe menu_item_urldimension.Selectitanditwillbeincludedinthelistofpossibledimensionsinthereport. IfyouCANNOTseethemenu_item_url(orwhatevercustomparameterareyoulookingfor),youmustregisterthatcustomparameterinConfigure>Events>ManageCustomDefinitions.Andthenwaitfor24hoursuntilthedataappearsinthereports.Ifthereportsdon’tworkproperly,waitforevenlonger. Thenlet’sedittheTabsettings.RemovetheexistingdimensionsintheROWSandincludethecustomdefinitionthatyouwanttoinclude.Inmycase,that’s menu_item_url. IntheCOLUMNSsection,IusedtheDevicecategorydimension.IntheVALUESsection,selectthemetricthatyouwishtosee.IusedtheEventCount. Thenyouwillneedtofilteronlytothoseeventsthatactuallycontainedthemenu_item_urldimension.Inmycase,thatisjusta menu_clickevent.That’swhyatthebottomofthe TabSettings section,youshouldenterafilter: Eventname exactlymatches  menu_click. That’sit,yourreportwillnowdisplayhowdifferentdevicecategoriesareclickingmenuitems;whichonesarethemostpopularandhowmanytimesweretheyclicked. Also,don’tforgettochangethedaterangeifyouneedit.Youcandothatinthetop-leftcorneroftheExplorationinterface. Youcanalsouseeventdatainthingslikefunnelreports,butlet’skeepitforanothertutorial(hopefully)inthefuture.   Howtoplanyoureventnamingconventionandstructure Note: Thischapterwillbejustanoverviewofhowyoushoulddoit.Hopefully,inthefuture,Iwillwriteadedicatedarticlejustforthat(onceIspendevenmoretimewithGoogleAnalytics4). Speakingofactualplanning,Iwouldsaythataspreadsheetisyourbestfriend. Writedownalltheeventsthatyouwanttotrackandthen: Checkwhethertheyfallunderthecategories:automaticallycollected,enhancedmeasurement,orrecommended. Ifyes,checkthenamingconventionofeventnamesandparameters(dimensions).Ifnot,thencomeupwithyourownvalues.Justkeepinmindthattherearesomelimitationsrelatedtothelength. Ifyouhaveahugelistofeventnames,beawareofanotherlimitation.Currently,youcanhaveupto500uniqueeventsperproperty.Ifyouareclosetothatlimitinyourspreadsheet,maybeitwouldmakesensetocombinesomeeventsunderthesameeventnameandintroduceanadditionalproperty(currently,thelimitofregisteredcustompropertiesare50textpropertiesand50numericproperties.Moreaboutregisteredproperties–laterinthispost). Update:the“500uniqueeventnamesperproperty”doesnotapplytowebevents.Learnmore Hereisanexampleofthespreadsheetwithevents thatyoucouldprepareyourselfandthentrytopicktherightnamingconvention.Youcanuseitasanexample/inspirationtocomeupwithyourownspreadsheet.Let’stakeaquickoverviewofthespreadsheet. Therearetwosheets: Thefirstoneisforthelistofeventsandwhatkindofparametersdoyouwanttotracktogetherwiththem Thesecondoneisalistofparameterswiththeirexplanations Thefirstsheet: IncolumnB,youcanjustbrieflydescribeaneventinplainEnglish IncolumnA,youshouldenterthenameoftheeventthatyouwilluseinGoogleAnalytics4.Youshouldpickthisnamebasedonthepreviouslydescribedprocess:checktheautomaticallytrackedevents,enhancedmeasurement,andrecommendedevents.Ifnoneoftheeventsmatchyours,thenaddacustomname.Itlooksprettycleantousethisprincipletonametheevent,e.g. event_name(alllowercaseandconnectedwithanunderscore).Eventnameslike“SubmittedtheForm”willalsowork,buttheall-lower-case-with-underscorelookscleaner(Ibelievethatthetermsnake-caseapplieshere). ColumnCisfortype(isitAutomaticallycollected,EnhancedMeasurement,RecommendedorCustom?). ColumnDisforparametersthatyouwant/plantotrackwithparticularevents.Ididnotincludedefaultparametersthatareautomaticallytrackedwitheveryevent: language,page_location,page_referrer,page_title,screen_resolution. Ifyouaredealingwithmobileappsaswell,youcouldincludeanadditionalcolumn“Platform”whereyoucouldenter“web”or“Android/iOS”. Thesecondsheet: ColumnAisfortheparametername ColumnBisforaplatform.Ifyouareworkingjustwiththewebsite,feelfreetoremovethatcolumn. ColumnCisthetype(isitBuilt-in,Recommended,orCustom).Built-inmeansthatitisusedbyautomaticallytrackedeventsorEnhancedMeasurement.Recommendedparametersareforrecommendedevents.Customparametersareyourownuniqueevents. ColumnDisfordescription(inplainEnglish). IMPORTANT:Thisspreadsheetisjustanexample.Youdon’thavetoblindlyfollowit.Ifyouwish,youcantakejustsomepartsandadaptittoyourneeds. Onceyoupreparetheplan,thenyoucantrackeventswithGoogleAnalytics4.Don’trushtoosoon.Otherwise,youmightfacetheconsequencesinthelongrun.   EventlimitsinGoogleAnalytics4 Anotherthingtokeepinmindthattherearesomelimits(andsomearegone(atleastfornow?).Iwouldalwaysrecommendforyoutorefertothispage whenitcomestolimits.Mostlikely,itwillbemoreup-to-dateinthefuturethanmyblogpost. Anyway,herearesomeofthethingsyoushouldremembernow: Thereisnolimitforeventsintotal(atleastfornow).InUniversalAnalytics(freeaccount),theallowedlimitofhitperpropertywas10million.Atthecurrentmoment,thereisnosuchlimitinGoogleAnalytics4.Butyouneverknowwhatmighthappeninthefuture🙂 Youcanhaveupto500uniqueeventnamesperproperty(EnhancedMeasurementeventsarenotcounted).SoifyouhaveaneventcalledloginandalsoLogin,thesewillbecountedastwouniqueeventnames.I’venoticedsomepeoplesayingthatrecommendedeventsarenotcountedtowardsthe500limit(andthattheyheardthisfromGoogle’ssupport).Ihavealsospokenwithmanypeople,includingCharlesFarinaandheconfirmedthatrecommendedeventsarecountedtowardsthe500eventlimit. Youcanhaveupto50customdimensionsand50custommetricsregisteredinaproperty.Thekeywordhereis registered.ThismeansthatyouhavetogotoConfigure> Events>Managecustomdefinitionsandhavethemconfiguredthere.Ifyousendmorecustomparametersbuttheyarenotregistered,you’refine. Youcansendupto25parameterswithanevent Therearesomelengthlimitsforeventnamesandparametersaswell.Both(theeventnameandtheparametername)mustbeupto40-characters-long. Tolearnmoreaboutthelimits,asalways,refertothispage.   UsefulresourcesonhowtotrackeventswithGoogleAnalytics4 Herearesomegoodresourcesthatyoumightfinduseful: Automaticallycollectedevents (byGoogle) Enhancedmeasurement Recommendedevents CustomDimensions CustomMetrics Collectionandconfigurationlimits (byGoogle) 5bestpracticesforcreatingyoureventsandparametersinGA4 (byKenWilliams)   TrackEventswithGoogleAnalytics4and GoogleTagManager:FinalWords Phew!Thatwasalongguide!IexpectedittobelengthybutnotTHATMUCH.However,eventtrackinginGoogleAnalytics4isaveryextensivetopichencethelengthoftheblogpostisjustproofofthat.Andthealmost-one-hour-longYoutubetutorialsupportsthatstatement. Tosumup,here’sistherecommendedprocessofhowyoushouldtrackeventswithGoogleAnalytics4: ChecktheautomaticallytrackedeventsandwhatEnhancedMeasurementhastooffer. Ifanevent(thatyouwishtotrack)isnotlistedthere,checktherecommendedeventsandtrytousetheirnamingrecommendnamesandparameters. Ifnoneoftherecommendedeventsmatchyourneed,thencreateacustomevent Herearesomeofthekeytakeawaysofthisblogpost.However,ifyoujustskimmedthearticle,pleasereaditcarefully(andifyouhavetime,watchthevideoaswell).Therearemanygotchasthere. EverythingisnowaneventinGoogleAnalytics4.Evenpageviews. Nomore EventCategory,EventAction,EventLabelfields.Ifyouwant,youcancreatethemmanuallyascustomparametersbutthatdoesnotmakesense. ThereisnolimitforthetotalnumberofeventsinaGoogleAnalytics4property(e.g.youcanhave1billioneventssenttoGAifyouwant).Butthelistofuniqueeventnamescannotbelargerthan500(pervisitor/user).EnhancedMeasurementeventsarenotcountedinthat500-limit. Youcansendcustomparameters(dimensionsandmetrics)withevents(bothrecommendandcustom). Youcansendupto25parameterswithasingleevent. IfyouwanttoseeaparameterintheGA4report,youmustregisteritasacustomdefinition.Thereisalimitof50-registeredcustomdimensionsand50registeredcustommetricsperproperty. YoucancreateneweventsintheGA4interfacebasedonincomingevents. Youcanmodify/fixincomingeventsintheGA4interface(e.g.iftherearesometypos) IfyouarethinkingaboutmigratingyourUniversalAnalyticseventstoGA4,don’tjustblindlyreuse EventAction,Category,and Labelfields.It’stimeforyoutorethinkyournamingconventionandparameters. Therearesomeotherlimitsaswell(regardingthelengthofnames/parameters,etc.) UseGoogleAnalytics4DebugViewtotesttheincomingeventsonagranularlevel. GotmorequestionsabouthowtotrackeventswithGoogleAnalytics4?Posttheminthecommentsbelow!   JuliusFedorovicius InGoogleAnalyticsTips Search Hi,I'mJuliusFedoroviciusandI'mheretohelpyoulearnGoogleTagManagerandGoogleAnalytics.Jointhousandsofotherdigitalmarketersanddigitalanalystsinthisexcitingjourney.Readmore



請為這篇文章評分?