Measurement protocol V2 Google analytics Apps+Web
文章推薦指數: 80 %
https://www.google-analytics.com/g/collect?v=2&_dbg=1&tid=G-EYPV5EM8S1&cid=1487972805.1593070957&dl=https%3A%2F%2Flunaxod.com&sid= ... Skiptocontent RecentPosts BuildingGTMServersideclient BulkwithdrawalLinkedInoldpendinginvitation SetBusystatusfromadditionalGooglecalendars MeasurementprotocolV2GoogleanalyticsApps+Web TrendsforeCommerceaccordingtoCOVID-19 InRingostat,historically,wehaveintegrationwithGoogleAnalyticsfromthebeginning.Thatisarequirement. Ascalltracking,weneedtopostdataaboutphonecallstosessionsofclients,sotheywillcountasevents,decreasebounce,andcanbeusedasgoals. WithGoogleUniversalAnalyticsandreleaseofmeasurementprotocol,thisintegrationbecamemuchbetter,andthefirstcallweregisteredthroughmeasurementprotocolonDecember29th,2012,itwasinclosedbetaforthatmoment.AsIknow,wewerethefirstcalltrackingservicetodothat,butImadeabigmarketingmistakenottousethisincommunication. Buttimemovesforward,andGoogleAnalyticshasanewstageinbetaApps+Web,andwegotaclientthatusesthattypeofaccount.Andwediscoveredthatourintegrationdoesn’tworkbecauseofnewcollectendpointandentirelydifferentwayeventsworkthere. ButthereisstillsolowamountofinformationtheonlyusefularticleIfoundfromDavidVallejo,butit’snotcurrentlycoverwhatmandatoryfieldsareandhowtogettheirvalues. Sointhisarticle,I’llshareasummaryofminetriesandfails.Whichfieldsmandatoryandhowtofillthem. Sameaspreviously,weneedtosenddatatocollectendpoint,butnowithasanotherURL.Alsochangedtheprotocolversion,nowit’s2.AndthewayhowtrackingIDnowlookslikeandnowit’snottrackingIDbutstreamID,andyoucanhavedifferentstreamsforoneproperty. Still,youneedclientIDtopostdatatothesameclient,buttogetitnow,youneedtoget‘vid’propertyof‘gaGlobal’object.Justcall‘gaGlobal.vid’injavascriptinsteadga.getAll()[0].get(‘clientId’)asyoucoulddopreviously.ThereisalotofotherdifferencesthatI’llnotcoverinthisarticle.Butthemaindifferenceformeisnewparams: SessionID,forsessionID,usedUNIXtimestampofsessionstartandstoredinthenewcookiethathasanamelike_ga_XXXXXXXXXwhereXXXXXXXXXisstreamIDwithoutG-.Sessioncount,numberofsessionsforthisclientId.Weirdthing,butitlookslikethisisrequired,butitalsostoredinthecookie. ToparsethosevariablesfromthecookieinonelineImodifiedsuggestedsnippetsofcodeto: document.cookie.match('(^|;)\\s*_ga_XXXXXXXXX\\s*=\\s*([^;]+)').pop().split('.')[2] JustfixXXXXXXXXXwithyoursstreamID. Longstoryshort,weneedtobuildtherequestwiththeparametersthatIfoundasrequiredandstillsendittohttps://www.google-analytics.com/g/collect.IfoundstrangeinformationthatIhavetouseonlyPOSTrequestwithseparationsomeparametersinURLandotherinpayload,butGETworksfinealso.Sotheparamsare ParametermeaningWhatshouldweuseherevProtocolVersion2tidStreamIDG-XXXXXXXXX(findinaccountoryourcode)cidClientIDjavascript:gaGlobal.vidsidSessionIDjavascript:document.cookie.match(‘(^|;)\\s*_ga_XXXXXXXXX\\s*=\\s*([^;]+)’).pop().split(‘.’)[2]sctSessionCountjavascript:document.cookie.match(‘(^|;)\\s*_ga_XXXXXXXXX\\s*=\\s*([^;]+)’).pop().split(‘.’)[3]dlDocumentlocationjavascript:document.locationenEventnamestring,howyouwanttonameyoureventex.‘call’ Also,it’sgoodtoadd_dbg=1fordebuggingtoseedatainrealtimeatDebugView(extremelycoolfeature!). AftercollectionsuchparamsyoucanbuildURLthatwouldlooklike: https://www.google-analytics.com/g/collect?v=2&_dbg=1&tid=G-EYPV5EM8S1&cid=1487972805.1593070957&dl=https%3A%2F%2Flunaxod.com&sid=1593070957&sct=1&en=call Callit,andin10seconds,seetheeventinDebugViewifyouhavedoneeverythingright.Afterthat,youcanimprovethiscallwithadditionaleventparamsanduserparams. Postnavigation PreviousPreviouspost:TrendsforeCommerceaccordingtoCOVID-19NextNextpost:SetBusystatusfromadditionalGooglecalendars
延伸文章資訊
- 1GA4 Measurement Protocol API 使用教學與應用範例 - 數據酷
https://www.google-analytics.com/mp/collect. 正式伺服器,傳送的數據會進入GA4 資源,通訊協定有誤時,不會出現錯誤警告。
- 2Measurement protocol V2 Google analytics Apps+Web
https://www.google-analytics.com/g/collect?v=2&_dbg=1&tid=G-EYPV5EM8S1&cid=1487972805.1593070957&...
- 3What is Google Analytics and how does it work? - TechTarget
- 4How Google Analytics Collects Data - AnalyticsMarket
- 5Measurement Protocol in Google Analytics - Tutorial
POST http://www.google-analytics.com/collect. Transport is made up of: #1 GET/POST method – which...