1. Home
  2. Docs
  3. API Documentation
  4. Active APIs
  5. getCampaignAnalytics

getCampaignAnalytics

Description

This API fetches all the analytics of a campaign / message.

Specifying a message ID of an email / SMS will retrieve the analytics of ALL its sendings carried out – if the message was sent to different lists, if it was sent on different days or at different timings, if it was sent via the Juvlon App / API, etc. The API will also provide the overall accumulated analytics of the message.

Specifying a campaign will return the analytics of ALL the sendings of ALL the sent messages (email/SMS) belonging to the specified campaign, along with the overall accumulated analytics of each sent message. Any unsent messages belonging to the campaign will not be listed in the response.

Hence, you need to specify either a campaign /or a message. If, however, both are specified, then the API will retrieve all the analytics of the message.

The analytics is returned in a JSON format in the API’s response. Please refer to the “Return Values” section below for the details of the analytics that will be retrieved.

This API needs to be called using an HTTP Post method with data in JSON format as shown below.

URL: https://api2.juvlon.com/v4/getCampaignAnalytics

'{
              "apiKey":"$apiKey",
              "messageID":"$messageID",
              "campaignName":"$campaignName"
 }';

Arguments

NameTypeDescriptionDefault
apiKeyStringMandatory. The apiKey that gives you access to our HTTP APIs. The apiKey authenticates you and helps us to identify your Juvlon account. 
messageIDIntThe ID of a email / SMS message whose analytics are to be retrieved. 
campaignNameStringThe name of a campaign whose analytics are to be retrieved. 

Return values

Name Type Description
code String The Success or Error response code as returned by the API. Please refer to the section “Possible-Response-Codes” for more details.
status String Description of the error code returned.
transactionID String A number generated by the API to uniquely identify the current call. Also known as the API_Call_ID.
campaignName String The name of the campaign to which the message(s) whose analytics are being retrieved belong.
campaignID Int The ID of the campaign to which the message(s) whose analytics are being retrieved belong.
campaignCreationDate String The date of creation of the campaign to which the message(s) whose analytics are being retrieved belong.
messages A list / array of all messages as per the campaign / message specified in the API request, and their analytics.
Each item in this list will be a key-value pair:
  • The key will be the message ID, and
  • The value will contain all the data for each message like the message’s subject, ID, its analytics etc. (described in detail below).
The following return values are returned for each message in the list:
messageID Int The ID of the message whose analytics are being retrieved.
messageType String The type of the message whose analytics are being retrieved – email / SMS
subject String The subject of the message whose analytics are being retrieved.
creationDate String The date of creation of the message whose analytics are being retrieved.
sender String The sender of the message whose analytics are being retrieved.
isTransactional String “Yes” – if the message is a transactional email / sms
“No” – if the message is not a transactional email / sms
linkTracking String “Yes” – if the links in the message are tracked.
“No” – if the links in the message are not tracked.
over all Analytics Contains the overall analytics of each message.
sendings A list / array of all sendings of each message.

A message may be sent multiple times at different dates/times, and via different methods (using the Juvlon UI or using an API). Each of these is called a separate “sending”.
The following return values are returned for each sending of each message:
sentOn String The date and time when the sending was carried out.
lists An array of all the lists to which the message was sent to in the current sending.
Each item in this array will be a key-value pair:
  • The key will be the list’s name, and
  • The value will contain all the data for each list like the list’s name (again), the list’s ID, and its analytics (described in detail below).
The following return values are returned for each list that the message was sent to in the current sending:
listName String The name of a list to which the message was sent.
listID Int The ID of a list to which the message was sent.
The following return values are returned for the overallAnalytics of each message, and for each sending of each message to each list:
sent Int The number of recipients to which the email/SMS was sent in the current/overall sending.
opens Int The count of all opens received in the current/overall sending.
* Provided for emails only
uniqueOpens Int The count of all unique opens (no. of recipients who opened atleast once) in the current/overall sending.
* Provided for emails only
bounces Int The count of hard bounces received in the current/overall sending.
* Provided for emails only
optOuts Int The count of opt-outs (recipients who unsubscribed) received in the current/overall sending.
* Provided for emails only
complaints Int The count of spam complaints received in the current/overall sending.
* Provided for emails only
usage Int The count of actual SMS messages sent in the current/overall sending.

This is different from the count of recipients when the size of an SMS message is larger and each message is sent out as 2 or more actual SMS. Thus if a big message (that needs to be sent out in 2 SMS each) is sent to 100 recipients, then the “sent” count will be 100, but the “usage” will be 200.
* Provided for SMS messages only
delivered Int The count of recipients to who the SMS message was delivered in the current/overall sending.
* Provided for SMS messages only
nonDelivered Int The count of recipients to who the SMS message was not delivered in the current/sendingsll sending.
* Provided for SMS messages only
DND Int The count of recipients to who the SMS message could not be delivered because they were registered for the “Do not disturb” service at the time.
* Provided for SMS messages only
clicks Int The count of clicks received in the current/overall sending.* Provided for Emails and SMS messages 
* Provided for Emails and SMS messages
clickedLinks A list / array of the links that were clicked in the current/overall sending.
The following return values are returned for each link that was clicked in the current/overall sending:
link String The url of the link that was clicked.
linkID Int The ID of the link that was clicked.
clicks Int The count of clicks received for the current link

Usage / Example(s)
PHP Example Code for Integration

$url = 'https://api2.juvlon.com/v4/getCampaignAnalytics';
 $data = '{"apiKey":"KEY",
           "messageID":"1",
           "campaignName":"ABC"
           }'; 
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
 $res1 = curl_exec($ch);
 curl_close($ch);

Success-Response

HTTP/1.1
  {
     "code":"200",
     "status":"Success",
     "transactionID":"13228",
     "campaignName": "Promotions",
     "campaignID": "2",
     "campaignCreationDate": "2022-08-13 09:10:56",
     "messages": {
		  "1850": {
	                    "messageID": "1850",
	                    "messageType": "email",
	                    "subject": "My First email",
		            "creationDate": "2022-08-23 09:15:45",
			    "sender": "john@abc.com",
			    "isTransactional": "yes",
			    "linkTracking": "yes",
		            "overallAnalytics": {
				         "sent": "1100",
			                 "opens": "100",
                                         "uniqueOpens": "70",
					 "clicks": "50",
					 "clickedLinks":  [{
						    "link": "url1",
						    "linkID": "21",
						    "clicks": "20"
						 },
						 {
						    "link": "url2",
						    "linkID": "22",
						    "clicks": "30"
						 }
					 ],
					 "bounces": "1",
					 "optOuts": "0",
					 "complaints": "0"
			    },
			    "sendings":  [{
				 "sentOn": "2022-08-23 09:30:45",
				 "lists": {
                                       "ListA": 
                                             {
                                             "listName": "ListA",
                                             "listID": "123",
                                             "sent": "509",
                                             "opens": "322",
                                             "uniqueOpens": "212",
                                             "clicks": "135",
                                             "clickedLinks":[{
                                                     "link": "url1",
                                                     "linkID": "21",
                                                     "clicks": "101"
                                                    },
                                                    {
                                                    "link": "url2",
                                                    "linkID": "22",
                                                    "clicks": "34"
                                                  }
                                             ],
                                             "bounces": "1",
                                             "optOuts": "0",
                                             "complaints": "0"
                                        },
                                        "ListB": {
                                             "listName": "ListB",
                                             "listID": "124",
                                             "sent": "456",
                                             "opens": "185",
                                             "uniqueOpens": "93",
                                             "clicks": "92",
                                             "clickedLinks":  [{
                                                    "link": "url1",
                                                    "linkID": "21",
                                                    "clicks": "36"
                                                   },
                                                   {
                                                    "link": "url2",
                                                    "linkID": "22",
                                                    "clicks": "56"
                                                   }
                                             ],
                                             "bounces": "0",
                                             "optOuts": "0",
                                             "complaints": "0"
                                             }
                                   },
                                   {
                                   "sentOn": "2022-08-22 09:30:45",
                                   "lists": {.....}
                                   },
                                   {
                                   "sentOn": "2022-08-20 09:30:45",
                                   "lists": {.....}
                                   }
                              ]
                         },
			"1851": {
				 "messageID": "1851",
				 "messageType": "SMS",
				 "subject": "Thanks for signing up…",
			         "creationDate": "2022-08-15 09:15:45",
				 "sender": "SYGBKI",
				 "isTransactional": "yes",
				 "linkTracking": "yes",
				 "overallAnalytics": {...},
				 "sendings": [{
				 "sentOn": "2022-08-23 09:30:45",
					  "lists": {
                                              "ListA": {
                                                "listName": "ListA",
                                                "listID": "123",
                                                "sent": "509",
                                                "usage": "1018",
                                                "delivered": "322",
                                                "clicks": "135",
                                                "clickedLinks": [{
                                                    "link": "url1",
                                                    "linkID": "21",
                                                    "clicks": "101"
                                                   },
                                                   {
                                                   "link": "url2",
                                                   "linkID": "22",
                                                   "clicks": "34"
                                                   }
                                             ],
                                             "nonDelivered": "1",
                                             "DND": "0"
                                            },
					   "ListB": {}
				     },
			             {
					"sentOn": "2022-08-23 09:30:45",
					"lists": {...}
                                     }
				    ]}
		}
	}
  } 

Error-Response

HTTP/1.1
    {
       "code":402,
       "status":"Error"
    } 

Possible-Response-Codes

 200    Success: API Request Accepted
 401    Error: Invalid Method
 402    Error: Unauthorized/Empty Key
 403    Error: Unauthorized/Invalid Key
 404    Error: Account Sending Blocked
 405    Error: Your Juvlon account is expired
 448    Error: Your Juvlon account is Deactivated
 482    Error: Invalid Message ID
 483    Error: Campaign name does not exist in your Juvlon Account
 484    Error: Invalid Sent ID
 485    Error: No campaign / message / sentID specified
 486    Error: Message not sent
 501    Error: Severe server error. Try later