Jump to content

GetCampaignReports()

Return a list of finished campaigns and a count of how many finished campaigns exist. Start and End dates can be set to limit the search. Returns a max of 200 campaigns.

Parameters

ApiKey (Required)
    Your application authentication key. Click here to find out more.
StartIndex (Optional)
    The zero-based index offset at which to start listing the results. If left blank, the list will start at index 0 (i.e. the beginning).
StartDate (Optional)
    The date from which to filter results, using the format YYYY-MM-DD. If not provided, the method will search from the beginning of time.
EndDate (Optional)
    The date to which results should be filtered, using the format YYYY-MM-DD. If not provided, the method will include all campaigns sent through today.

Return Value

On success, this method returns the following information:

Campaign Count - the total number of campaigns that match the specified date criteria; since this method returns a maximum of 200 campaigns at a time, if the total exceeds 200, you can invoke the method with the appropriate StartIndex to retrieve the remaining campaigns.

Campaigns - a list of the campaigns that match the specified StartIndex and date criteria, up to 200.  For each campaign, the following information is included:

  • CampaignReportID - the unique ID of the sent campaign, which can be used with methods such as CampaignSummary
  • Name - the name of the email campaign
  • Date Started - the specific date/time the email campaign started to send out, in ISO 8601 format, YYYY-MM-DDThh:mm:ss.sTZD (example: 2011-05-21T15:30:45.00+05:00, or May 21, 2011 3:30pm GMT+5)
  • Date Finished - the specific date/time the email campaign completed sending, in ISO 8601 format, YYYY-MM-DDThh:mm:ss.sTZD (example: 2012-12-21T11:11:00.00-04:00, or December 21, 2012 11:11am Eastern Time). If the campaign has not finished or is in the paused/stopped status, Date Finished will come back as an empty string.
  • Subject (NEW in version 2.1) - the subject line of the sent email
  • IsTest (NEW in version 2.1) - a bit (integer) value indicating whether the sent campaign was a test (1) or not (0)
  • Lists - an array containing the ListID of each contact list that was sent the campaign

On failure, a SOAP fault exception is thrown with one of the fault codes below.

Usage Notes

StartDate and EndDate are matched up with the date/time each campaign finished sending. If at least a StartDate is specified, unfinished campaigns will not be included; otherwise, if StartDate is left blank — regardless of whether or not EndDate is specified — unfinished campaigns will be included in the results.

Fault Codes

100 - Invalid API Key
    The API key is not valid or expired

SOAP Sample Request


    
    
        
            
                STRING
                INT
                STRING
                STRING
            
        
    

SOAP Sample Response


    
    
        
            
                INT
                
                    
                        INT
                        STRING
                        STRING
                        STRING
                    
                     ... 
                
            
        
    

Code Sample - PHP

// Import the eConnect Email API Toolkit
require_once('eConnectEmail_API_Toolkit.php');

$eConnectEmailApi = TheKeyMakerClient('YOUR_API_KEY');

$result = $eConnectEmailApi->GetCampaignReports(START_INDEX, 'START_DATE', 'END_DATE');

// Show the results
print 'Response: <pre>';
print_r($result);
print '</pre>';

Code Sample - ASP.NET C#

            TheKeyMaker_v20 api = new TheKeyMaker_v20();
            // Set up input parameters
            DateRangeParams gcParams = new DateRangeParams();
            gcParams.ApiKey = txtApiKey.Text;
            gcParams.StartIndex = (txtGCRStartIndex.Text.Trim() != "") ? int.Parse(txtGCRStartIndex.Text) : 0;
            gcParams.StartDate = txtGCRStartDate.Text;
            gcParams.EndDate = txtGCREndDate.Text;

            // Invoke method and store result
            ReturnCampaigns campaigns = api.GetCampaignReports(gcParams);

            // Display results
            lblResult.Text = FormatValue("Total # of Campaigns", campaigns.CampaignCount.ToString());
            if (campaigns.Campaigns != null)
            {
                lblResult.Text += "

Campaigns and the List ID(s) used by each:

    "; foreach (CampaignResult campaign in campaigns.Campaigns) { lblResult.Text += "
  • " + campaign.Name + " (ID " + campaign.CampaignReportID.ToString() + "), started " + campaign.DateStarted + ", finished " + (campaign.DateFinished == "" ? "N/A" : campaign.DateFinished) + " -- ListID "; string lists = ""; foreach (ListIdResult list in campaign.Lists) { lists += list.ListID.ToString() + ", "; } lblResult.Text += lists.TrimEnd(new char[] { ',', ' ' }); } lblResult.Text += "
"; } else lblResult.Text += "

No campaign reports exist with the specified criteria.

";