示例#1
0
 /// <summary>Snippet for RunReport</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void RunReportRequestObject()
 {
     // Create client
     BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
     // Initialize request argument(s)
     RunReportRequest request = new RunReportRequest
     {
         Property           = "",
         Dimensions         = { new Dimension(), },
         Metrics            = { new Metric(), },
         DateRanges         = { new DateRange(), },
         DimensionFilter    = new FilterExpression(),
         MetricFilter       = new FilterExpression(),
         Offset             = 0L,
         Limit              = 0L,
         MetricAggregations =
         {
             MetricAggregation.Unspecified,
         },
         OrderBys            = { new OrderBy(), },
         CurrencyCode        = "",
         CohortSpec          = new CohortSpec(),
         KeepEmptyRows       = false,
         ReturnPropertyQuota = false,
     };
     // Make the request
     RunReportResponse response = betaAnalyticsDataClient.RunReport(request);
 }
示例#2
0
 /// <summary>Snippet for RunRealtimeReport</summary>
 public void RunRealtimeReportRequestObject()
 {
     // Snippet: RunRealtimeReport(RunRealtimeReportRequest, CallSettings)
     // Create client
     BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
     // Initialize request argument(s)
     RunRealtimeReportRequest request = new RunRealtimeReportRequest
     {
         Property           = "",
         Dimensions         = { new Dimension(), },
         Metrics            = { new Metric(), },
         DimensionFilter    = new FilterExpression(),
         MetricFilter       = new FilterExpression(),
         Limit              = 0L,
         MetricAggregations =
         {
             MetricAggregation.Unspecified,
         },
         OrderBys            = { new OrderBy(), },
         ReturnPropertyQuota = false,
         MinuteRanges        = { new MinuteRange(), },
     };
     // Make the request
     RunRealtimeReportResponse response = betaAnalyticsDataClient.RunRealtimeReport(request);
     // End snippet
 }
示例#3
0
 /// <summary>Snippet for GetMetadata</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetMetadataResourceNames()
 {
     // Create client
     BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
     // Initialize request argument(s)
     MetadataName name = MetadataName.FromProperty("[PROPERTY]");
     // Make the request
     Metadata response = betaAnalyticsDataClient.GetMetadata(name);
 }
示例#4
0
 /// <summary>Snippet for GetMetadata</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetMetadata()
 {
     // Create client
     BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
     // Initialize request argument(s)
     string name = "properties/[PROPERTY]/metadata";
     // Make the request
     Metadata response = betaAnalyticsDataClient.GetMetadata(name);
 }
 /// <summary>Snippet for GetMetadata</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetMetadataRequestObject()
 {
     // Create client
     BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
     // Initialize request argument(s)
     GetMetadataRequest request = new GetMetadataRequest
     {
         MetadataName = MetadataName.FromProperty("[PROPERTY]"),
     };
     // Make the request
     Metadata response = betaAnalyticsDataClient.GetMetadata(request);
 }
示例#6
0
 /// <summary>Snippet for BatchRunReports</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void BatchRunReportsRequestObject()
 {
     // Create client
     BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
     // Initialize request argument(s)
     BatchRunReportsRequest request = new BatchRunReportsRequest
     {
         Property = "",
         Requests =
         {
             new RunReportRequest(),
         },
     };
     // Make the request
     BatchRunReportsResponse response = betaAnalyticsDataClient.BatchRunReports(request);
 }
示例#7
0
 /// <summary>Snippet for CheckCompatibility</summary>
 public void CheckCompatibilityRequestObject()
 {
     // Snippet: CheckCompatibility(CheckCompatibilityRequest, CallSettings)
     // Create client
     BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
     // Initialize request argument(s)
     CheckCompatibilityRequest request = new CheckCompatibilityRequest
     {
         Property            = "",
         Dimensions          = { new Dimension(), },
         Metrics             = { new Metric(), },
         DimensionFilter     = new FilterExpression(),
         MetricFilter        = new FilterExpression(),
         CompatibilityFilter = Compatibility.Unspecified,
     };
     // Make the request
     CheckCompatibilityResponse response = betaAnalyticsDataClient.CheckCompatibility(request);
     // End snippet
 }
        static void SampleRunReport(string propertyId = "YOUR-GA4-PROPERTY-ID")
        {
            /**
             * TODO(developer): Uncomment this variable and replace with your
             *  Google Analytics 4 property ID before running the sample.
             */
            // propertyId = "YOUR-GA4-PROPERTY-ID";

            // [START analyticsdata_initialize]
            // Using a default constructor instructs the client to use the credentials
            // specified in GOOGLE_APPLICATION_CREDENTIALS environment variable.
            BetaAnalyticsDataClient client = BetaAnalyticsDataClient.Create();
            // [END analyticsdata_initialize]

            // [START analyticsdata_run_report]
            // Initialize request argument(s)
            RunReportRequest request = new RunReportRequest
            {
                Property   = "properties/" + propertyId,
                Dimensions = { new Dimension {
                                   Name = "city"
                               }, },
                Metrics = { new Metric {
                                Name = "activeUsers"
                            }, },
                DateRanges = { new DateRange {
                                   StartDate = "2020-03-31", EndDate = "today"
                               }, },
            };

            // Make the request
            var response = client.RunReport(request);

            // [END analyticsdata_run_report]

            // [START analyticsdata_run_report_response]
            Console.WriteLine("Report result:");
            foreach (Row row in response.Rows)
            {
                Console.WriteLine("{0}, {1}", row.DimensionValues[0].Value, row.MetricValues[0].Value);
            }
            // [END analyticsdata_run_report_response]
        }
 /// <summary>Snippet for RunPivotReport</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void RunPivotReportRequestObject()
 {
     // Create client
     BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
     // Initialize request argument(s)
     RunPivotReportRequest request = new RunPivotReportRequest
     {
         Property            = "",
         Dimensions          = { new Dimension(), },
         Metrics             = { new Metric(), },
         DateRanges          = { new DateRange(), },
         Pivots              = { new Pivot(), },
         DimensionFilter     = new FilterExpression(),
         MetricFilter        = new FilterExpression(),
         CurrencyCode        = "",
         CohortSpec          = new CohortSpec(),
         KeepEmptyRows       = false,
         ReturnPropertyQuota = false,
     };
     // Make the request
     RunPivotReportResponse response = betaAnalyticsDataClient.RunPivotReport(request);
 }
示例#10
0
        /// <summary>Snippet for RunReport</summary>
        public void RunReportRequestObject()
        {
            // Snippet: RunReport(RunReportRequest, CallSettings)
            // Create client
            BetaAnalyticsDataClient betaAnalyticsDataClient = BetaAnalyticsDataClient.Create();
            // Initialize request argument(s)
            RunReportRequest request = new RunReportRequest
            {
                Property           = "",
                Dimensions         = { new Dimension(), },
                Metrics            = { new Metric(), },
                DateRanges         = { new DateRange(), },
                DimensionFilter    = new FilterExpression(),
                MetricFilter       = new FilterExpression(),
                MetricAggregations =
                {
                    MetricAggregation.Unspecified,
                },
                OrderBys            = { new OrderBy(), },
                CurrencyCode        = "",
                CohortSpec          = new CohortSpec(),
                KeepEmptyRows       = false,
                ReturnPropertyQuota = false,
            };
            // Make the request
            PagedEnumerable <RunReportResponse, DimensionHeader> response = betaAnalyticsDataClient.RunReport(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (DimensionHeader item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (RunReportResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (DimensionHeader item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <DimensionHeader> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (DimensionHeader item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }