Sending events | Measurement Protocol for Google Analytics 4

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

This guide explains how to format and send requests to the Google Analytics Measurement Protocol. Sending events. To send an event, make an HTTP ... Google Analytics Measurement MeasurementProtocol(GoogleAnalytics4) Language English BahasaIndonesia Deutsch Español Français Português–Brasil Русский 中文–简体 日本語 한국어 Signin Guides Reference Support Google Analytics Measurement MeasurementProtocol(GoogleAnalytics4) Guides Reference Support Overview Fundamentals SendingeventsValidatingeventsVerifyImplementationUserpropertiesTroubleshooting Resources Protocol/SDK/UserIDPolicy Demos&Tools EventBuilderFirebaseCodelabforAppStreams Home Products GoogleAnalytics Measurement MeasurementProtocol(GoogleAnalytics4) Sendingevents Overview ThisguideexplainshowtoformatandsendrequeststotheGoogleAnalytics MeasurementProtocol. Sendingevents Tosendanevent,makeanHTTPPOSTrequesttothefollowingendpoint: POST/mp/collectHTTP/1.1 HOST:www.google-analytics.com Content-Type:application/json Note:TheMeasurementProtocolforGoogleAnalytics4onlysupportsPOST requests. Requiredparameters Avalidrequestrequirestwosetsofparametersthatvaryifyou'reusing Firebaseorgtag.js: Firebase gtag.js URLparameters api_secret-Required.AnAPISECRETgeneratedintheGoogle AnalyticsUI.Tocreateanewsecret,navigateto: Admin>DataStreams>chooseyourstream>MeasurementProtocol>Create Seequeryparametersforthefullreference. JSONbody user_id-Optional.Auniqueidentifierforauser.See User-IDforcross-platformanalysisformoreinformationonthis identifier. Note:user_idmayonlycontainutf-8characters. events-Required.Anarrayofeventitems. SeeJSONPOSTBODYforthefullreference. Note:Tosendmorethanoneeventinonerequest,includemultipleeventsinthe eventsentry. Optionalparametersforreports InorderforuseractivitytodisplayinstandardreportslikeRealtime,engagement_time_msecandsession_idmustbesuppliedaspartoftheparamsforanevent. Example: { "client_id":"x", "events":[ { "name":"offline_purchase", "params":{ "engagement_time_msec":"100", "session_id":"123" } } ] } Whilesession_startisareservedeventname,creatinganewsession_idwilleffectivelycreateanewsessionwithouttheneedtosendsession_start. Note:Understandhowsessionsarecounted. Sendanevent Firebase gtag.js Tosendatutorial_beginevent,makethefollowingrequest: Limitations Requestscanhaveamaximumof25events. Eventscanhaveamaximumof25parameters. Eventscanhaveamaximumof25userproperties. Userpropertynamesmustbe24charactersorfewer. Userpropertyvaluesmustbe36charactersorfewer. Eventnamesmustbe40charactersorfewer,mayonlycontainalpha-numeric charactersandunderscores,andmuststartwithanalphabeticcharacter. Parameternames(includingitemparameters)mustbe40charactersorfewer, mayonlycontainalpha-numericcharactersandunderscores,andmuststart withanalphabeticcharacter. Parametervalues(includingitemparametervalues)mustbe100characteror fewer. Itemparameterscanhaveamaximumof10customparameters. Thepostbodymustbesmallerthan130kB. Exceptasotherwisenoted,thecontentofthispageislicensedundertheCreativeCommonsAttribution4.0License,andcodesamplesarelicensedundertheApache2.0License.Fordetails,seetheGoogleDevelopersSitePolicies.JavaisaregisteredtrademarkofOracleand/oritsaffiliates. Lastupdated2022-06-02UTC. [{ "type":"thumb-down", "id":"missingTheInformationINeed", "label":"MissingtheinformationIneed" },{ "type":"thumb-down", "id":"tooComplicatedTooManySteps", "label":"Toocomplicated/toomanysteps" },{ "type":"thumb-down", "id":"outOfDate", "label":"Outofdate" },{ "type":"thumb-down", "id":"samplesCodeIssue", "label":"Samples/codeissue" },{ "type":"thumb-down", "id":"otherDown", "label":"Other" }] [{ "type":"thumb-up", "id":"easyToUnderstand", "label":"Easytounderstand" },{ "type":"thumb-up", "id":"solvedMyProblem", "label":"Solvedmyproblem" },{ "type":"thumb-up", "id":"otherUp", "label":"Other" }] GitHub TryGoogleAnalyticssamples StackOverflow Askquestionsusingthegoogle-analyticstag Twitter Follow@googleanalyticsonTwitter Videos ViewGoogleAnalyticsvideosonYouTube Connect Community&Updates GettingHelp ReportinganIssue ProductInfo Protocol/SDKPolicy BrandingPolicy Developerconsoles GoogleAPIConsole GoogleCloudPlatformConsole GooglePlayConsole FirebaseConsole ActionsonGoogleConsole CastSDKDeveloperConsole ChromeWebStoreDashboard Android Chrome Firebase GoogleCloudPlatform Allproducts Terms Privacy SignupfortheGoogleDevelopersnewsletter Subscribe Language English BahasaIndonesia Deutsch Español Français Português–Brasil Русский 中文–简体 日本語 한국어



請為這篇文章評分?