Skip to main content
Solved

API feature request to get suitable conversion metrics for a report

  • February 11, 2025
  • 3 replies
  • 13 views

Forum|alt.badge.img

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. 

Best answer by Byrne C

Hi ​@mstypsan1,

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

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

Byrne C
Community Manager
Forum|alt.badge.img+12
  • Community Manager
  • 82 replies
  • Answer
  • February 12, 2025

Hi ​@mstypsan1,

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


MANSIR2094
Problem Solver IV
Forum|alt.badge.img+15
  • Problem Solver IV
  • 227 replies
  • February 12, 2025

Hello ​@mstypsan1  , Thank you for reaching out!

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!


Amos Peace
Problem Solver III
Forum|alt.badge.img+5
  • Problem Solver III
  • 62 replies
  • February 12, 2025

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=['GET']) def get_metrics(): report_type = request.args.get('reportType', '').lower() return jsonify({"reportType": report_type, "availableMetrics": METRICS.get(report_type, [])}) if __name__ == '__main__': app.run(debug=True)

 

This endpoint returns the available metrics based on the reportType parameter.

 

Best Regards.