Measurement protocol V2 Google analytics Apps+Web

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

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



請為這篇文章評分?