Simple interaction planning example
You are designing an interaction for a cellular phone company's website. The following diagram shows the layout for the cell phone plan summary page.
Sample web page showing interaction points
You define the following items to meet the requirements for the cell phone plan summary page.
One offer to be displayed in a zone that is dedicated to offers about upgrades
*
The area on the page displaying the upgrade offer must be defined. Also, once Interact picks an offer to display, the information must be logged.
Interaction point: ip_planSummaryBottomRight
Event: evt_logOffer
Two offers for phone upgrades
*
Interaction point: ip_planSummaryTopRight
Interaction point: ip_planSummaryBottomLeft
For analysis, you need to log which offers are accepted, and which are rejected.
Event: evt_offerAccept
Event: evt_offerReject
You also know that you must pass the treatment code of an offer whenever you log an offer contact, acceptance, or rejection. Where necessary, you create a NameValuePair to contain the treatment code, as in the following example.
NameValuePair evtParam_TreatmentCode = new NameValuePairImpl();
evtParam_TreatmentCode.setName("UACIOfferTrackingCode");
evtParam_TreatmentCode.setValueAsString(offer.getTreatmentCode());
evtParam_TreatmentCode.setValueDataType(NameValuePair.DATA_TYPE_STRING);
Now you can ask the design environment user to create the interaction points and events for you while you start to code the integration with your touchpoint.
For each interaction point that will display an offer, you need to first get an offer, then extract the information you need to display the offer. For example, request an offer for the lower right area of your web page (planSummaryBottomRight)
Response response=getOffers(sessionID, ip_planSummaryBottomRight, 1)
This returns a response object including an OfferList response. However, your web page can not use an OfferList object. You need an image file for the offer, which you know is one of the offer attributes (offerImg). You need to extract the offer attribute you need from the OfferList.
OfferList offerList=response.getOfferList();
if(offerList.getRecommendedOffers() != null)
{
Offer offer = offerList.getRecommendedOffers()[0];
NameValuePair[] attributes = offer.getAdditionalAttributes();
for(NameValuePair attribute: attributes)
{
if(attribute.getName().equalsIgnoreCase("offerImg"))
{
/* Use this value in your code for the page, for
example: stringHtml = "<img src="+attribute.getValueAsString()+ " > */
}
}
}
Now that you are displaying the offer, you want to log it as a contact.
NameValuePair evtParam_TreatmentCode = new NameValuePairImpl();
evtParam_TreatmentCode.setName("UACIOfferTrackingCode");
evtParam_TreatmentCode.setValueAsString(offer.getTreatmentCode());
evtParam_TreatmentCode.setValueDataType(NameValuePair.DATA_TYPE_STRING);
postEvent(
sessionID, evt_logOffer, evtParam_TreatmentCode)
Instead of calling each of these methods singularly, you can use the executeBatch method, as shown in the following example for the planSummaryBottomLeft portion of the web page.
Command getOffersCommand = new CommandImpl();
getOffersCommand.setMethodIdentifier(Command.COMMAND_GETOFFERS);
getOffersCommand.setInteractionPoint(ip_planSummaryBottomLeft);
getOffersCommand.setNumberRequested(1);

Command postEventCommand = new CommandImpl();
postEventCommand.setMethodIdentifier(Command.COMMAND_POSTEVENT);
postEventCommand.setEvent(evt_logOffer);

/** Build command array */
Command[] commands =
{
getOffersCommand,
postEventCommand
};

/** Make the call */
BatchResponse batchResponse = api.executeBatch(
sessionId, commands);
You do not need to define the UACIOfferTrackingCode in this example because the Interact runtime server automatically logs the last recommended list of treatments as contacts if you do not supply the UACIOfferTrackingCode.
You have also written something to change the image displayed every 30 seconds for the second area on the page displaying a phone upgrade offer. You have decided to rotate between three images, so should you should use the following to retrieve the set of offers to cache for use in your code to rotate the images.
Response response=getOffers(sessionID, ip_planSummaryBottomLeft, 3)
OfferList offerList=response.getOfferList();
if(offerList.getRecommendedOffers() != null)
{
for(int x=0;x<3;x++)
{
Offer offer = offerList.getRecommendedOffers()[x];
if(x==0)
{
// grab offerimg attribute value and store somewhere;
// this will be the first image to display
}
else if(x==1)
{
// grab offerimg attribute value and store somewhere;
// this will be the second image to display
}
else if(x==2)
{
// grab offerimg attribute value and store somewhere;
// this will be the third image to display
}
}
}
You must write your client code fetch from the local cache and log to contact only once for each offer after its image has been displayed. To log the contact, the UACITrackingCode parameter needs to be posted as before. Each offer will have a different tracking code.
NameValuePair evtParam_TreatmentCodeSTR = new NameValuePairImpl();
NameValuePair evtParam_TreatmentCodeSBR = new NameValuePairImpl();
NameValuePair evtParam_TreatmentCodeSBL = new NameValuePairImpl();

OfferList offerList=response.getOfferList();
if(offerList.getRecommendedOffers() != null)
{
for(int x=0;x<3;x++)
{
Offer offer = offerList.getRecommendedOffers()[x];
if(x==0)
{
evtParam_TreatmentCodeSTR.setName("UACIOfferTrackingCode");
evtParam_TreatmentCodeSTR.setValueAsString(offer.getTreatmentCode());
evtParam_TreatmentCodeSTR.setValueDataType(NameValuePair.DATA_TYPE_STRING);
}
else if(x==1)
{
evtParam_TreatmentCodeSBR.setName("UACIOfferTrackingCode");
evtParam_TreatmentCodeSBR.setValueAsString(offer.getTreatmentCode());
evtParam_TreatmentCodeSBR.setValueDataType(NameValuePair.DATA_TYPE_STRING);
}
else if(x==2)
{
evtParam_TreatmentCodeSBL.setName("UACIOfferTrackingCode");
evtParam_TreatmentCodeSBL.setValueAsString(offer.getTreatmentCode());
evtParam_TreatmentCodeSBL.setValueDataType(NameValuePair.DATA_TYPE_STRING);
}
}
}
For each offer, if the offer is clicked, you should log the offer accepted and the offers rejected. (In this scenario, offers not explicitly selected are considered rejected.) The following is an example if the ip_planSummaryTopRight offer is selected:
postEvent(sessionID, evt_offerAccept, evtParam_TreatmentCodeSTR)
postEvent(sessionID, evt_offerReject, evtParam_TreatmentCodeSBR)
postEvent(sessionID, evt_offerReject, evtParam_TreatmentCodeSBL)
In practice, it would be best to send these three postEvent calls with the executeBatch method.
This is a basic example, and does not show the best way to write the integration. For example, none of these examples include any error checking using the Response class.