Skip to main content
Contributor I
February 11, 2025
Solved

API feature request to get suitable conversion metrics for a report

  • February 11, 2025
  • 3 replies
  • 80 views

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

    3 replies

    Byrne C
    Community Manager
    Byrne CAnswer
    Community Manager
    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
    Expert Problem Solver IV
    Expert Problem Solver IV
    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!

    Mansir Digital Portfolio
    Amos Peace
    Problem Solver III
    Problem Solver III
    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.

    Peace - Turning Emails Into Opportunities 💼 Email Marketing Specialist | 🚀 Klaviyo Expert 📧 amosfolashade2@email.com WhatsApp -+2349023453575 “Delivering the right message, to the right person, at the right time.”