テンプレート分析

特定のWhatsAppビジネスアカウント(WABA)のテンプレート分析を取得するには、このエンドポイントを使用します。テンプレートが送信、配信、閲覧された回数、テンプレート内のURLボタンやクイック返信ボタンがクリックされた回数が分かります。

ボタンのクリック解析は、次のように分類されたテンプレートでのみ利用可能です。 MARKETING または UTILITY.データはUTCタイムゾーンで1日単位、最大90日間のルックバックで返される。

各コード・スニペットで使用されているすべての変数の説明を以下に示します:

キー説明
CHANNEL_MANAGER_WABA_ID

The waba_id of the WhatsApp Business Account (WABA) for which to retrieve the template analytics data.

VONAGE_API_KEY

Your Vonage API key (see it on your dashboard).

VONAGE_API_SECRET

Your Vonage API secret (also available on your dashboard).

CHANNEL_MANAGER_WHATSAPP_ANALYTICS_START

The start date and time in ISO-8601 format for the analytics data to be retrieved from, in the format YYYY-MM-DD.

CHANNEL_MANAGER_WHATSAPP_ANALYTICS_END

The end date and time in ISO-8601 format for the analytics data to be retrieved to, in the format YYYY-MM-DD. The maximum difference between the start and end dates is 90 days.

CHANNEL_MANAGER_WHATSAPP_ANALYTICS_TEMPLATE_IDS

An array of the template_ids of the template(s) to retrieve analytics for.

Prerequisites

If you do not have an application you can create one. Make sure you also configure your webhooks.

Write the code

Add the following to get-template-analytics.sh:

curl -G https://api.nexmo.com/v1/channel-manager/whatsapp/wabas/"${CHANNEL_MANAGER_WABA_ID}"/template-analytics \
  -u "${VONAGE_API_KEY}:${VONAGE_API_SECRET}" \
  -H 'Accept: application/json' \
  --data-urlencode start=$CHANNEL_MANAGER_WHATSAPP_ANALYTICS_START \
  --data-urlencode end=$CHANNEL_MANAGER_WHATSAPP_ANALYTICS_END \
  --data-urlencode template_ids=$CHANNEL_MANAGER_WHATSAPP_ANALYTICS_TEMPLATE_IDS

View full source

Run your code

Save this file to your machine and run it:

bash get-template-analytics.sh