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
延伸文章資訊
- 1Measurement protocol V2 Google analytics Apps+Web
https://www.google-analytics.com/g/collect?v=2&_dbg=1&tid=G-EYPV5EM8S1&cid=1487972805.1593070957&...
- 2Google Analytics
Google Analytics lets you measure your advertising ROI as well as track your Flash, video, and so...
- 3Sending event data via measurement protocol in Google ...
Sending event data via measurement protocol in Google Analytics ... POST https://www.google-analy...
- 4Measurement Protocol Reference - Google Developers
https://www.google-analytics.com/collect. All data should be sent securely with the HTTPS protoco...
- 5Validating Google Analytics Hits With The Network Tab - Bounteous