google-analytics-api Tutorial - Getting started with...

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

The Google Analytics Embed API is a JavaScript library that allows you to easily create and embed a dashboard on a 3rd party website in a matter of minutes. It ... google-analytics-api Gettingstartedwithgoogle-analytics-api Authentication ErrorResponses Metadataapi Real-timeAPI ReportingAPI(Analyticsv4) google-analytics-api Gettingstartedwithgoogle-analytics-api Authentication ErrorResponses Metadataapi Real-timeAPI ReportingAPI(Analyticsv4) google-analytics-api Gettingstartedwithgoogle-analytics-api Remarks TheGoogleAnalyticsAPIsallowyoutoaccessdatawithinGoogleAnalytics.ItshouldnotbeconfusedwiththemeasurementprotocolwhichisusedforinsertingdataintoGoogleAnalytics. TheGoogleAnalyticsAPIissplitintoservalparts. GoogleAnalyticsReportingAPIs TheGoogleAnalyticsCoreReportingAPIv3givesyouaccesstomostofthereportdatainGoogleAnalytics.WiththeCoreReportingAPIyoucan: BuildcustomdashboardstodisplayGoogleAnalyticsdata. Savetimebyautomatingcomplexreportingtasks. IntegrateyourGoogleAnalyticsdatawithotherbusinessapplications. TheGoogleAnalyticsReportingAPIV4isthemostadvancedprogrammaticmethodtoaccessreportdatainGoogleAnalytics.WiththeGoogleAnalyticsReportingAPI,youcan: BuildcustomdashboardstodisplayGoogleAnalyticsdata. Automatecomplexreportingtaskstosavetime. IntegrateyourGoogleAnalyticsdatawithotherbusinessapplications. TheRealTimeReportingAPIenablesyoutorequestrealtimedata—forexample,realtimeactivityonaview—foranauthenticateduser. YoucanusetheRealTimeReportingAPIto: Displayactiveviewersofapageandcreateasenseofurgencyforuserslookingatanitemwithfiniteinventory. Displaythemostpopularcontentsuchasthetop10activepages. Createanddisplayarealtimedashboard. TheRealTimeReportingAPI,inlimitedbeta,isavailablefor developerpreviewonly.SignuptoaccesstheAPI. TheMulti-ChannelFunnelsReportingAPIenablesyoutorequestMulti-ChannelFunnelsdataforanauthenticateduser.Dataisderivedfromconversionpathdata,whichshowsuserinteractionswithvarioustrafficsourcesovermultiplesessionspriortoconverting.Thisallowsyoutoanalyzehowmultiplemarketingchannelsinfluenceconversionsovertime.Formoredetailsonwhatdataisavailable,readtheAboutMulti-ChannelFunnels,aswellasAboutMulti-ChannelFunnelsData.WiththeMulti-ChannelFunnelsReportingAPIyoucan: CreatecustomreportsusingMulti-ChannelFunnelsdata.Forexample,youcouldusetheTopConversionPathsdatatoreportonattributessuchasrelativepositionofinteractionsinaconversionpath. IntegrateMulti-ChannelFunnelsdatawithyourbusinessdata.Forexample,youcouldcorrelateonlineconversiondatawithofflinesalesdataandmediacostdatatoarriveatamorecompletepictureofmarketingROI. DisplayMulti-ChannelFunnelsinnewenvironments.Forinstance,youcouldcreatevisualizationsandotherpresentationsofthedatathatcommunicatethevalueofdifferentmarketingchannelsindrivingconversions. Helpers TheMetadataAPIreturnsthelistandattributesofcolumns(i.e.dimensionsandmetrics)exposedintheGoogleAnalyticsreportingAPIs.AttributesreturnedincludeUIname,description,segmentssupport,andmore.YoucanusetheMetadataAPIto: Automaticallydiscovernewcolumns. AccessalldimensionsandmetricsattributesforGoogleAnalyticsreportingAPIs. Note:ThisonlyreturnsmetadatafortheCoreReportingAPIandthe ReportingAPI.Notreal-timemetadata. TheGoogleAnalyticsEmbedAPIisaJavaScriptlibrarythatallowsyoutoeasilycreateandembedadashboardona3rdpartywebsiteinamatterofminutes.Itgivesyouasetofpluggablecomponentsthatcanworktogethertobuildcomplextools,makingitbothsimpleandpowerfulatthesametime. ConfigurationAPIs TheAnalyticsManagementAPIallowsforprogrammaticaccesstotheGoogleAnalyticsconfigurationdata.YoucanbuildapplicationstomoreefficientlymanagelargeorcomplexAnalyticsaccounts.Largecompanieswithmanypropertiescanautomateaccountsetup.EvenifyouarebuildingareportingapplicationtheManagementAPIprovidesyoutoolstonavigateyouraccount.YoucanusetheGoogleAnalyticsManagementAPIto: ListalltheAccount,PropertyandViewinformationforauser. ManageProperties,Views,andGoals. Manageuserpermissionsforanaccounthierarchy. RetrieveaViewIDtousewiththeCoreReportingAPI. Determinewhichgoalsareactiveandaccesstheirconfigurednames. ManageLinksbetweenAnalyticspropertiesandAdWordsaccounts. ManageRemarketingAudiences. WriteoperationsintheManagementAPI(e.g.create,update,delete, patch)forWebProperty,View(Profile),andGoalresourcesis currentlyavailableasadeveloperpreviewinlimitedbeta.If you'reinterestedinusingthesefeatures,requestaccesstothe beta. TheProvisioningAPIcanbeusedtocreatenewGoogleAnalyticsaccountsandenableGoogleAnalyticsforyourcustomersatscale.Itisintendedforqualifiedserviceprovidersandlargepartners.Forexample,youcouldusetheProvisioningAPIaspartofanewuseronboardingprocesstocreateanewGoogleAnalyticsaccountforaclientandthenuseadditionalManagementAPIresourcestoprogrammaticallyconfiguretheaccountandlinkittoAdWords.Thiscanallbeautomatedandinitiatedfromwithinyourownadminorreportinginterface. TheProvisioningAPIisavailablebyinvitationonly.Wearenot currentlyacceptingnewprojects. Versions TherearecurrentlythreeversionsoftheGoogleAnalyticsAPIlive. GoogleAnalyticsV2Version2.4oftheCoreReportingAPIisanXML-onlyAPIthatismostlybackwardscompatiblewithversion2.3.(Legacy) GoogleAnalyticsV3whichincludestheCoreReportingAPI,ManagementAPI,MetaDataAPIandannumberofotherAPIs.TheseAPIsreturnJson GoogleAnalyticsV4whichcurrentlyonlyincludesthereportingAPIandisconsideredtobethemostadvancedwayofretrievingreportingdatafromGoogleAnalytics. AccessingGoogleAnalyticsAPIs YoucantechnicallyaccesstheGoogleAnalyticsAPIsusinganyprograminglanguagethatcanhandleaHTTPPostorHTTPGetrequest. Thatbeingsaid,Googlehasalsocreatedanumberofofficialstandardclientlibrariestohelpyouwiththis.Usingastandardclientlibraryforyourchosenprogramminglanguagecanbemucheasierthancodingitfromthegroundupyourself. OFFICALClientlibrarieswithGoogleAnalyticsAPIsupport: GoogleAPIsPHPClientlibrary-GitHub GoogleAPIs.NetClientlibrary-GitHubNuGet GoogleAPIsPythonClientlibrary-GitHub GoogleAPIsJavaClientlibrary-link GoogleAPIsObjective-Clibrary-GitHub Therearemorelibrarieshere. Introduction TheGoogleAnalyticsAPIsallowyoutoaccessdatawithinGoogleAnalytics.ItshouldnotbeconfusedwiththemeasurementprotocolwhichisusedforinsertingdataintoGoogleAnalytics. TheGoogleAnalyticsAPIissplitintoservalparts. GoogleAnalyticsReportingAPIs TheGoogleAnalyticsCoreReportingAPIv3givesyouaccesstomostofthereportdatainGoogleAnalytics.WiththeCoreReportingAPIyoucan: BuildcustomdashboardstodisplayGoogleAnalyticsdata. Savetimebyautomatingcomplexreportingtasks. IntegrateyourGoogleAnalyticsdatawithotherbusinessapplications. TheGoogleAnalyticsReportingAPIV4isthemostadvancedprogrammaticmethodtoaccessreportdatainGoogleAnalytics.WiththeGoogleAnalyticsReportingAPI,youcan: BuildcustomdashboardstodisplayGoogleAnalyticsdata. Automatecomplexreportingtaskstosavetime. IntegrateyourGoogleAnalyticsdatawithotherbusinessapplications. TheRealTimeReportingAPIenablesyoutorequestrealtimedata—forexample,realtimeactivityonaview—foranauthenticateduser. YoucanusetheRealTimeReportingAPIto: Displayactiveviewersofapageandcreateasenseofurgencyforuserslookingatanitemwithfiniteinventory. Displaythemostpopularcontentsuchasthetop10activepages. Createanddisplayarealtimedashboard. TheRealTimeReportingAPI,inlimitedbeta,isavailablefor developerpreviewonly.SignuptoaccesstheAPI. TheMulti-ChannelFunnelsReportingAPIenablesyoutorequestMulti-ChannelFunnelsdataforanauthenticateduser.Dataisderivedfromconversionpathdata,whichshowsuserinteractionswithvarioustrafficsourcesovermultiplesessionspriortoconverting.Thisallowsyoutoanalyzehowmultiplemarketingchannelsinfluenceconversionsovertime.Formoredetailsonwhatdataisavailable,readtheAboutMulti-ChannelFunnels,aswellasAboutMulti-ChannelFunnelsData.WiththeMulti-ChannelFunnelsReportingAPIyoucan: CreatecustomreportsusingMulti-ChannelFunnelsdata.Forexample,youcouldusetheTopConversionPathsdatatoreportonattributessuchasrelativepositionofinteractionsinaconversionpath. IntegrateMulti-ChannelFunnelsdatawithyourbusinessdata.Forexample,youcouldcorrelateonlineconversiondatawithofflinesalesdataandmediacostdatatoarriveatamorecompletepictureofmarketingROI. DisplayMulti-ChannelFunnelsinnewenvironments.Forinstance,youcouldcreatevisualizationsandotherpresentationsofthedatathatcommunicatethevalueofdifferentmarketingchannelsindrivingconversions. Helpers TheMetadataAPIreturnsthelistandattributesofcolumns(i.e.dimensionsandmetrics)exposedintheGoogleAnalyticsreportingAPIs.AttributesreturnedincludeUIname,description,segmentssupport,andmore.YoucanusetheMetadataAPIto: Automaticallydiscovernewcolumns. AccessalldimensionsandmetricsattributesforGoogleAnalyticsreportingAPIs. Note:ThisonlyreturnsmetadatafortheCoreReportingAPIandthe ReportingAPI.Notreal-timemetadata. TheGoogleAnalyticsEmbedAPIisaJavaScriptlibrarythatallowsyoutoeasilycreateandembedadashboardona3rdpartywebsiteinamatterofminutes.Itgivesyouasetofpluggablecomponentsthatcanworktogethertobuildcomplextools,makingitbothsimpleandpowerfulatthesametime. ConfigurationAPIs TheAnalyticsManagementAPIallowsforprogrammaticaccesstotheGoogleAnalyticsconfigurationdata.YoucanbuildapplicationstomoreefficientlymanagelargeorcomplexAnalyticsaccounts.Largecompanieswithmanypropertiescanautomateaccountsetup.EvenifyouarebuildingareportingapplicationtheManagementAPIprovidesyoutoolstonavigateyouraccount.YoucanusetheGoogleAnalyticsManagementAPIto: ListalltheAccount,PropertyandViewinformationforauser. ManageProperties,Views,andGoals. Manageuserpermissionsforanaccounthierarchy. RetrieveaViewIDtousewiththeCoreReportingAPI. Determinewhichgoalsareactiveandaccesstheirconfigurednames. ManageLinksbetweenAnalyticspropertiesandAdWordsaccounts. ManageRemarketingAudiences. WriteoperationsintheManagementAPI(e.g.create,update,delete, patch)forWebProperty,View(Profile),andGoalresourcesis currentlyavailableasadeveloperpreviewinlimitedbeta.If you'reinterestedinusingthesefeatures,requestaccesstothe beta. TheProvisioningAPIcanbeusedtocreatenewGoogleAnalyticsaccountsandenableGoogleAnalyticsforyourcustomersatscale.Itisintendedforqualifiedserviceprovidersandlargepartners.Forexample,youcouldusetheProvisioningAPIaspartofanewuseronboardingprocesstocreateanewGoogleAnalyticsaccountforaclientandthenuseadditionalManagementAPIresourcestoprogrammaticallyconfiguretheaccountandlinkittoAdWords.Thiscanallbeautomatedandinitiatedfromwithinyourownadminorreportinginterface. TheProvisioningAPIisavailablebyinvitationonly.Wearenot currentlyacceptingnewprojects. HelloWorldReportingAPI-Rest POSThttps://analyticsreporting.googleapis.com/v4/reports:batchGet?access_token={Accesstokenfromauthrequest} { "reportRequests":[ { "viewId":"XXXX", "dateRanges":[ { "startDate":"2015-06-15", "endDate":"2015-06-30" }], "metrics":[ { "expression":"ga:sessions" }], "dimensions":[ { "name":"ga:browser" }] }] } Previous Next ThismodifiedtextisanextractoftheoriginalStackOverflowDocumentationcreatedbyfollowingcontributorsandreleasedunderCCBY-SA3.0 ThiswebsiteisnotaffiliatedwithStackOverflow SUPPORT&PARTNERS Advertisewithus Contactus PrivacyPolicy STAYCONNECTED Getmonthlyupdatesaboutnewarticles,cheatsheets,andtricks.  Subscribe



請為這篇文章評分?