I would like to have an API endpoint that will retuen the available metrics for a report. For example when I make an API request for Query Campaign Values, I don’t know exactly which conversion metrics are suitable out of all the metrics that my account has.
Hi
I definitely understand how this would be useful. Happy to reach out to our product team and recommend that we implement this in the future. I see how it would be helpful to know which conversion metrics are able to be used in that API call,
-Byrne
Hello
You can use Klaviyo’s Get Metrics API to retrieve all available metrics in your account. This will help you identify which conversion metrics are suitable for your report.
Make a GET request to:https://a.klaviyo.com/api/metrics/
Include your private API key in the header. This will return a list of metrics, and you can filter based on relevance to your campaign.
Let me know if you need help refining the request or automating the process!
To create an API endpoint that returns available metrics for a report follow these steps:
1. API Request
GET /api/available-metrics?reportType=campaign
2. API Response Example
{ "reportType": "campaign", "availableMetrics": :"impressions", "clicks", "conversions", "revenue", "CTR", "ROI"] }
3. Simple Flask Backend
from flask import Flask, request, jsonify app = Flask(__name__) METRICS = { "campaign": ""impressions", "clicks", "conversions", "revenue", "CTR", "ROI"], "ad_group": ""cost", "click_through_rate", "conversion_rate"] } @app.route('/api/available-metrics', methods=d'GET']) def get_metrics(): report_type = request.args.get('reportType', '').lower() return jsonify({"reportType": report_type, "availableMetrics": METRICS.get(report_type, e])}) if __name__ == '__main__': app.run(debug=True)
This endpoint returns the available metrics based on the reportType
parameter.
Best Regards.
Log in to the Community
Use your Klaviyo credentials
Log in with Klaviyo
Use your Klaviyo credentials
Log in with KlaviyoEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.