0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Google Business Profile APIs] accounts.locations.reportInsights → locations.getDailyMetricsTimeSeries移行時のタイムゾーンを調べる

Posted at

サポート終了と代替手段への移行

2022/02/20に、Google マイビジネス v4.9のaccounts.locations.reportInsightsaccounts.locations.localPosts.reportInsightsは廃止となるため、前者については、Google Business Profile Performance API v1locations.getDailyMetricsTimeSeriesで置き換える必要があります(後者は代替手段なし)。

accounts.locations.reportInsightsとaccounts.locations.localPosts.reportInsightsについては、時刻については RFC3339 UTC のZulu形式のタイムスタンプ が用いられていますが、locations.getDailyMetricsTimeSeriesに関しては、公式サイトを見ると以下の記載があります。

TimeOfDay
1 日のうちの時刻を表します。日付とタイムゾーンは意味を持たないか、他の場所で指定されています。

書き方が曖昧すぎて、どこのタイムゾーンを基準にしているのか、わからない。。
困りました。。

解決方法

自分は調査に半日強かかってしまいましたが、、

サポート終了スケジュール | Google Business Profile APIs

を見ればわりと簡単なことで、accounts.locations.reportInsightsとlocations.getDailyMetricsTimeSeriesの対応する項目を任意の期間で取得して、比較すればよいだけのお話でした。

比較対象となるのは、以下3項目です。

accounts.locations.reportInsights locations.getDailyMetricsTimeSeries 意味
ACTIONS_WEBSITE WEBSITE_CLICKS ウェブサイトがクリックされた回数
ACTIONS_PHONE CALL_CLICKS 通話ボタンがクリックされた回数
ACTIONS_DRIVING_DIRECTIONS BUSINESS_DIRECTION_REQUESTS 受信した予約の数

accounts.locations.reportInsightsは時分秒まで、locations.getDailyMetricsTimeSeriesについては、日付を指定してAPIを叩き、前者の時刻指定をずらしながら、後者と上記3項目が一致する時刻を探します。

accounts.locations.reportInsights

https://mybusiness.googleapis.com/v4/{name=accounts/*}/locations:reportInsights

送信時に指定する項目(POST)

  • locationName,
  • 開始日時、終了日時

locations.getDailyMetricsTimeSeries

https://businessprofileperformance.googleapis.com/v1/locations/12345:getDailyMetricsTimeSeries?dailyMetric=WEBSITE_CLICKS&dailyRange.start_date.year=2022&dailyRange.start_date.month=12&dailyRange.start_date.day=1&dailyRange.end_date.year=2022&dailyRange.end_date.month=12&dailyRange.end_date.day=1

送信時に指定する項目(GET)

  • locationName
  • dailyMetric
  • 開始日、終了日

自分の使用環境の場合は、前者の前日15:00~当日15:00まで(例: 10/12 15:00 ~10/13 15:00)の値が、後者の当日(10/13)の値と一致していたため、タイムゾーンは日本ということになりました。

終わりに

Googleさん、書き方わかりにくすぎるやろ。。
せめてどうやったら基準となるタイムゾーンを確認できるか、書いてくれることを切に望みます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?