Service: GetCampaignHistory

The GetCampaignHistory service allows you to request a complete history or a history of a selection of actions for all email addresses in a campaign. Default all actions will be selected. From the moment a CampaignHistoryOptionsType is passed it will overrule the default setting.

Service Details

SOAP Action: GetCampaignHistory
SOAP Return Object: GetCampaignHistoryResp

Input

The following table describes the parameters used for calling the GetCampaignHistory service.

Table: instance of GetCampaignHistoryReq

Parameter Mandatory Type Description
header Y APIRequestHeader Header for authentication
campaignId Y Integer Campaign to get the history for
timestampFrom / String Start history from this date
timestampTill / String Stop history at this date
campaignHistoryOptionsType / CampaignHistoryOptionsType Object to select which actions should be included in the history
sort / Integer Sort the results by time, default ASC:

0 = ASC
1 = DESC

Output

The following table describes the parameters returned from the GetCampaignHistory service.

Table: instance of GetCampaignHistoryResp

Parameter Mandatory Type Description
header / APIResponseHeader Header containing authentication information
errorCode / Integer Numerical value of the error
errorMessage / String Short literal description of the error
campaignHistoryType / CampaignHistoryType The requested history

Table: response codes of GetCampaignHistoryResp.

0 No error
220 Authentication error, see header object for detailed information
221 Invalid campaign

Example

This example shows you how to request all campaigns read and clicked actions performed by all the receivers of campaign 123 performed in the year 2010.

<?php
$header->userId = USER_ID;
$header->userToken = USER_TOKEN;

// create the new GetEmailAddressHistoryRequest
$request->header = $header;

// set the email address to request the history for
$request->campaignId = 123;

// optionally set a start time and or a stop stop
$request->timestampFrom = "2010-01-01T00:00:00";
$request->timestampTill = "2010-12-31T23:59:59";

// optionally create an options object to select the preferred actions
$options = new stdClass();
$options->campaignRead = true;
$options->linkClicked = true;

// add these options to the request
$request->campaignHistoryOptionsType = $options;

// execute the request
$response = $SoapClient->__soapCall("GetCampaignHistory", array($request));

// Check for errors
if ($response->errorCode == 0) {
	echo "History recieved";

	foreach ($response->campaignHistoryType->emailAddressHistoryTypeItems as $email) {
		foreach ($email->emailAddressHistoryActionTypeItems as $action) {
			echo $action->actionId . "-" . $action->timestamp . "<br />";
			
			switch ($action->actionId) {
			case 18:
				echo "Read campaign: " . $action->campaign->value . "<br />";
				break;

			case 20:
				echo "Clicked on a link:" . $action->link->value . "<br />";
				break;
			}
		}
	}
} else {
	echo "Could not retrieve email address history: " . $response->errorMessage;
}
?>