Get Campaign Report API

Overview

The Get Campaign Report API lets you get campaign metrics.

To get a campaign report, you specify the id of the report needed. If the campaign has not completed yet, you will receive an error message indicating that status.

Base URL

https://api.clevertap.com/1/targets/result.json

HTTP Method

POST

Headers

These headers are all required. The X-CleverTap-Account-Id and X-CleverTap-Passcode are used to authenticate the request. Please see the authentication guide to see how to get their values.

Header
Description
Type
Example Value

X-CleverTap-Account-Id

Your CleverTap Account ID.

string

"X-CleverTap-Account-Id: ACCOUNT_ID"

X-CleverTap-Passcode

Your CleverTap Account Passcode.

string

"X-CleverTap-Passcode: PASSCODE"

Content-Type

Request content-type is always set to application/json.

string

"Content-Type: application/json"

Body Parameter

The body is uploaded as a JSON payload.

Parameter
Description
Type
Example Value

id

CleverTap campaign id of the campaign whose metrics you want to view. You can find this id in your CleverTap dashboard under the Push section

int

1457432766

Below is an example payload.

{
    "id": 1457432766
}

Example Request

curl -X POST -d '{ "id": 1457432766}' "https://api.clevertap.com/1/targets/result.json" \
-H "X-CleverTap-Account-Id: ACCOUNT_ID" \
-H "X-CleverTap-Passcode: PASSCODE" \
-H "Content-Type: application/json"
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://api.clevertap.com/1/targets/result.json")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request["X-Clevertap-Account-Id"] = "ACCOUNT_ID"
request["X-Clevertap-Passcode"] = "PASSCODE"
request.body = JSON.dump({
  "id" => 1457432766
})

req_options = {
  use_ssl: uri.scheme == "https",
}

response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
  http.request(request)
end
import requests

headers = {
    'X-CleverTap-Account-Id': 'ACCOUNT_ID',
    'X-CleverTap-Passcode': 'PASSCODE',
    'Content-Type': 'application/json',
}

data = '{ "id": 1457432766}'

response = requests.post('https://api.clevertap.com/1/targets/result.json', headers=headers, data=data)
<?php
include('vendor/rmccue/requests/library/Requests.php');
Requests::register_autoloader();
$headers = array(
    'X-CleverTap-Account-Id' => 'ACCOUNT_ID',
    'X-CleverTap-Passcode' => 'PASSCODE',
    'Content-Type' => 'application/json'
);
$data = '{ "id": 1457432766}';
$response = Requests::post('https://api.clevertap.com/1/targets/result.json', $headers, $data);
var request = require('request');

var headers = {
    'X-CleverTap-Account-Id': 'ACCOUNT_ID',
    'X-CleverTap-Passcode': 'PASSCODE',
    'Content-Type': 'application/json'
};

var dataString = '{ "id": 1457432766}';

var options = {
    url: 'https://api.clevertap.com/1/targets/result.json',
    method: 'POST',
    headers: headers,
    body: dataString
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);

Example Response

{
    "result": {
        "clicked": 28,
        "sent": 82
    },
    "status": "success"
}

Notes

If the campaign has not been completed yet, you will receive the error response below.

{
    "error": "This target hasn't been completed",
    "status": "fail"
}

Get Campaign Report API


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.