Simple interaction planning example
In this example, you are designing an interaction for a cellular phone company's website. You create three different offers, set up logging for the offers, assign treatment codes to the offer, and show a series of pictures that link to the offers.
Design process
To design an interaction for this client, you:
- Identify the requirements for the client's summary page
- Create interaction points for the offer requirements
- Configure logging for the offers
- Create treatment codes
- Link a series of rotating images to the offers
This example is basic, and does not show the best way to write the integration. For example, none of these examples include any error checking that uses the Response class.
Identify requirements for the cell phone plan summary page
The following diagram shows the layout for the cell phone plan summary page.
Requirement | Implementation |
---|---|
One offer to be displayed in a zone that is dedicated to offers about upgrades The area on the page that displays the upgrade offer must be defined. Also, after Interact picks an offer to display, the information must be logged. |
|
Two offers for phone upgrades Each area on the page that displays the phone upgrades must be defined. |
|
For analysis, you need to log which offers are accepted, and which offers are rejected. |
|
You also know that you must pass the treatment code of an offer whenever you log an offer contact, acceptance, or rejection. |
|
Display three rotating images on the page. Link the images to the offers. |
Create Interaction points
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 displays an offer, you need to first get
an offer, then extract the information that 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
response call returns a response object that includes an OfferList
response.
However, your web page cannot 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()+ " > */
}
}
}
Configure logging
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. The Interact runtime
server automatically logs the last recommended list of treatments
as contacts if you do not supply the UACIOfferTrackingCode
.
Create treatment codes
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);
Link images to offers
For the second area on the page that displays a phone upgrade, you wrote something to change the image displayed every 30 seconds. You decide to rotate between three images and you 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
is displayed. To log the contact, the UACITrackingCode
parameter
needs to be posted as before. Each offer has 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 log the offer that
is accepted and the offers that are 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.