How to set multiple metrics for setDailyMetric method while sending request to Business Profile Performance API?

648 views Asked by At

Following this link getDailyMetricsTimeSeries, I wanna have all the metrics in one request, since I have many locations for every client, it does not seem to be professional if I send one separate request for every single metric.

before in Google My business V4.9 we could use "ALL" to request all available metrics. Unfortunately, this is not working with the new API. Can I get ALL the metrics in ONE single request from Google Business Profile Performance API?

Here is my code in JAVA: supposing that the variable business_profile_performance is the initialiser global parameters via its Builder and also takes care of authentication.

try {

                BusinessProfilePerformance.Locations.GetDailyMetricsTimeSeries metricReport =
                        business_profile_perfomance.locations().
                        getDailyMetricsTimeSeries("My locationID" ).
                        setDailyMetric(dailyMetric).
                        setDailyRangeStartDateYear(Integer.valueOf("the desired start Year")).
                        setDailyRangeStartDateMonth(Integer.valueOf(" the desired start Month" )).
                        setDailyRangeStartDateDay(Integer.valueOf(" the desired start Day ")).

                        setDailyRangeEndDateYear(Integer.valueOf("the desired End Year" )).
                        setDailyRangeEndDateMonth(Integer.valueOf(" the desired End Month")).
                        setDailyRangeEndDateDay(Integer.valueOf("the desired End Day"));

                GetDailyMetricsTimeSeriesResponse response = metricReport.execute();
                if (!response.isEmpty()) {
                    System.out.println(dailyMetric + " Response == " + response);
                }

            } catch (Exception e) {
                System.out.println(e);
            }

I used a list for my dailyMetric variable, and using a for loop it takes turn as photo below:

enter image description here

2

There are 2 answers

0
Andrew Walker On BEST ANSWER

As of March 16th, 2023, Google added a new method locations.fetchMultiDailyMetricsTimeSeries that serves the same function as "ALL" in the old 4.9 API.

1
vpgcloud On

If setting dailyMetric to "CALL_CLICKS" works and setting it to "CALL_CLICKS,WEBSITE_CLICKS" does not work, it would seem that the new API does not support that use case anymore.