Miscellaneous Ramblings on Hacking

May 9, 2012

Unica Customer Insight–Creating custom Bins

Filed under: Unica — Zack Bethem @ 4:05 pm

Unica’s Customer Insight product can quickly generate an EasySet of data allowing a user to start mining their customer base. The problem comes into play when the out of box configuration doesn’t match what you want to display.

By default, CustomerInsight will take all numeric data types from the source table and create “bins”. The “bins” created sometimes do not align with the desired buckets that a business may be accustomed to. Follow this process to create your own bins.


We desire to set the bins for an attribute into 100 point increments to the following values:

  • 1 – 99
  • 100 – 199
  • 200 – 299
  • 300 – 399
  • 400 – 499
  • 900 – 1000

XML Modifications

File: cadimensions.xml

This file defines the bucket values that will be displayed. Within the existing <defaults><fields> tags, we will insert the following:

   1: <field name="ABILITY_TO_PAY">

   2:   <dimension name="ability_to_pay0" dimdisplay="Ability To Pay" singlefilterdisplay="Ability To Pay" multiplefilterdisplay="Ability To Pay" onlyincludedisplay="Ability To Pay" selectadisplay="%NTR_SELECTA_VALUE%" variable="ability_to_pay0code" filtertype="list" fill="true" keylookup="false" cgikey="abilitytopay0z">

   3:     <list source="self">

   4:       <item value="1" display="1 - 99" />

   5:       <item value="2" display="100 - 199" />

   6:       <item value="3" display="200 - 299" />

   7:       <item value="4" display="300 - 399" />

   8:       <item value="5" display="400 - 499" />

   9:       <item value="6" display="500 - 599" />

  10:       <item value="7" display="600 - 699" />

  11:       <item value="8" display="700 - 799" />

  12:       <item value="9" display="800 - 899" />

  13:       <item value="10" display="900 - 1000" />

  14:       <item value="11" display="0" />

  15:     </list>

  16:   </dimension>

  17: </field>

File: cavariables.xml

This file will create a variable for the translated codes. It defines the bins and maps those definitions back to the dimensions defined above. In the dimension definition above, note that we reference a variable ability_to_pay0code. This same variable name is used in the snippet below. The following would be inserted within the <defaults><fields> tags:

   1: <field name="ABILITY_TO_PAY">

   2:   <variable name="ability_to_pay0code">

   3:     <input type="db" entity="Fact1" element="ABILITY_TO_PAY">

   4:       <transformation type="intrange" destcolname="ability_to_pay0code" dbtype="int8">

   5:         <range start="1" end="99">1</range>

   6:         <range start="100" end="199">2</range>

   7:         <range start="200" end="299">3</range>

   8:         <range start="300" end="399">4</range>

   9:         <range start="400" end="499">5</range>

  10:         <range start="500" end="599">6</range>

  11:         <range start="600" end="699">7</range>

  12:         <range start="700" end="799">8</range>

  13:         <range start="800" end="899">9</range>

  14:         <range start="900" end="1000">10</range>

  15:         <range end="0">11</range>

  16:       </transformation>

  17:     </input>

  18:   </variable>

  19: </field>

File: caoutfmt.xml

This file defines the output format. Since we’ve modified the dimension and variables, the output format must also be defined. the following would be inserted within the <defaults><fields> tags:

   1: <field name="ABILITY_TO_PAY">

   2: <element name="ability_to_pay0" rowstoshow="10" showall="false" titleasc="Ability To Pay" titledsc="Ability To Pay">

   3:   <columns>

   4:     <column name="ability_to_pay0" type="listdimension" rankable="true" nowrap="true" trendable="true">

   5:       <header>Ability To Pay</header>

   6:       <format alignment="left" />

   7:       <exportfield>Ability To Pay</exportfield>

   8:       <datasettitle>Ability To Pay</datasettitle>

   9:     </column>

  10:   </columns>

  11:   <graph available="true">

  12:     <types>

  13:   <type default="true">bar</type>

  14:   <type>pie</type>

  15:   <type>line</type>

  16:     </types>

  17:   <crosstabtypes>

  18:     <crosstabtype>pathtab</crosstabtype>

  19:     <crosstabtype>barscape</crosstabtype>

  20:     <crosstabtype>barstacked</crosstabtype>

  21:   </crosstabtypes>

  22:   </graph>

  23: </element>

  24: field>


September 3, 2010

Unica Monitoring SQL

Filed under: Unica — Zack Bethem @ 11:43 pm

Doing some Unica troubleshooting today and wrote this little SQL gem. It’s a basic query that does a fine job of retrieving run log errors for flowchart runs. I figure it could come in handy as an Administrator asking the question:

What are my most common errors and where should I focus my troubleshooting?

The SQL:

select to_char(r.runstarttime,'yyyy-mm-dd') runday
, c.name campaign, f.name flowchart
, substr(rr.resultxml,instr(rr.resultxml,'<Process>')+9, instr(rr.resultxml,'<RunStatusCode>')-(instr(rr.resultxml,'<Process>')+9)) as process_name
, substr(rr.resultxml,instr(rr.resultxml,'<ErrorMessage>')+14, instr(rr.resultxml,'</ErrorMessage>')-(instr(rr.resultxml,'<ErrorMessage>')+14)) as result_error
, count(*)
from uacsys.ua_ccrunlog r
join uacsys.ua_runresult rr on r.runid=rr.runid
join uacsys.ua_flowchart f on r.flowchartid=f.flowchartid
join uacsys.ua_campaign c on f.campaignid=c.campaignid
where r.runstatus = 'Run Failed'
and r.runstarttime >to_date('2010-08-01','yyyy-mm-dd')
and instr(rr.resultxml,'<ErrorMessage>') &gt; 0
group by to_char(r.runstarttime,'yyyy-mm-dd')
, c.name, f.name
, substr(rr.resultxml,instr(rr.resultxml,'<Process>')+9, instr(rr.resultxml,'<RunStatusCode>')-(instr(rr.resultxml,'<Process>')+9))
, substr(rr.resultxml,instr(rr.resultxml,'<ErrorMessage>')+14, instr(rr.resultxml,'</ErrorMessage>')-(instr(rr.resultxml,'<ErrorMessage>')+14))
order by runday desc


This in turn creates some nice little results for analysis:

July 30, 2010

Unica Interact via SOAP – How To

Filed under: .Net, Unica — Zack Bethem @ 9:50 pm


Unica Interact extends Unica’s Campaign Suite for real-time offer management. If you want a full background of what it can offer, I’d suggest a read from Unica’s site. Here I’ll be discussing how to get started for some real basic integration. First, what you’ll need:

  • Unica’s v7 demo image or access to a Unica Interact implementation
  • Visual Studio 2008 (C# Express should work)

Interact Setup

When using the VMWare demo image provided, most of this is setup as part of the image. As an overview, however, I’ll review the following steps:

  1. Interactive Channel
  2. Session
  3. Assigned Campaign Offers and Ratings

Interactive Channel – Insurance

I’ll be using the already defined interactive channel Insurance. This is part of the Unica v7 demo image available to their partners. This interactive channel represents a website for an Insurance company and is defined with two zones, each with a single interaction point. One for home page landings, which would be the assumed landing page a user would see. Second, a signup page where a user would sign in based on existing credentials and/or register for first time use.


Interactive Session

From within the Interactive Channel summary tab, click on the related session Insurance. This will show the interactive session and its associated flowchart into focus for review.


Reviewing the associated flowchart, we see a simple segmentation of the incoming individual based on their related FICO score. Examining the process box FICO Score, the segmentation is as follows:

Low FICO Score Score < 200
Med FICO Score 200 < Score < 400
High FICO Score Score > 400


Lastly, examining the interaction process box Indiv_Id Profile the expected meta data for a session is shown along with the expected Audience. This will come into play later when the API initiates an interact session. For now, note that the audience level is Individual and the associated key is Indiv_Id. Also note the Score attribute in the record’s metadata used above for segmentation purposes.


Interactive Campaign

The last piece of the Interact puzzle is the associated interact campaign. Here is where the associated offers are defined by segment. I won’t go into the specifics as there is a complete User’s Guide for that, but here is where we can rank our offers. Note that some of the offers listed have expired, which is why they will not be shown later during the coding exercise. Also note that we have some offers tied directly to a given zone and that the offers have an associated ranking for presentation purposes.


Visual Studio Setup

With the review of the interact setup out of the way, it’s time prepare the VS environment for some coding. I’m using C# for this exercise which will limit me to using SOAP. Unica warns that the best performance is achieved using their interact_client.jar, but 1) I’m playing and 2) I’m not concerned with performance right now and 3) C# and .jar wouldn’t work to well and 4) I like C# more that I like java.

Import the WSDL

The WSDL for Interact can be found under:


Be sure to use the file from your installation as a version incompatibility could exist!

Once you have the WSDL downloaded, you can build a DLL out of it by doing the following steps:

  1. As administrator, open a Visual Studio command prompt. This is different from just a normal DOS prompt as it has environment settings. The link is in the start menu under the Visual Studio 2008 folder.
  2. Using the wsdl.exe utility, generate a C# Class
    wsdl /l:CS /protocol:SOAP \InteractService.wsdl
  3. Compile the proxy class as a DLL
    csc /t:library /r:System.Web.Services.dll /r:System.Xml.dll InteractService.cs

Visual Studio C# Console Program

Add a InteractService.DLL Reference

Create a new C# Console program. Once the project structure is created, we’ll reference the DLL that was compiled from above. Once does this by Right-Clicking on the Reference folder in the Solution Explorer window and opting for Add Reference..


Build a Helper Class

I created a helper class in my code. The class is basic as potatoes, but it allows for the quick definition of NameValuePairs. These name-value pairs are important as they define the session’s record structure. Recall I mentioned that earlier in reviewing the session’s metadata.

    class InteractHelper
        public NameValuePairImpl defineParm(string parmName, int valNumeric)
            NameValuePairImpl parm = new NameValuePairImpl();
            parm.name = parmName;
            parm.valueAsNumeric = valNumeric;
            parm.valueDataType = "numeric";
            return parm;
        public NameValuePairImpl defineParm(string parmName, string valString)
            NameValuePairImpl parm = new NameValuePairImpl();
            parm.name = parmName;
            parm.valueAsString = valString;
            parm.valueDataType = "string";
            return parm;
        public NameValuePairImpl defineParm(string parmName, DateTime valDate)
            NameValuePairImpl parm = new NameValuePairImpl();
            parm.name = parmName;
            parm.valueAsDate = valDate;
            parm.valueDataType = "datetime";
            return parm;

Note in the code that there are three defined valueDataTypes for the NameValue pairs. These are:

  1. numeric
  2. string
  3. datetime

Build Console Main()

Keep in mind that this is just a glorified HelloWorld program with the intention to get you started. That being said, the bulk of the code is just thrown into the Main method in the Console Program’s class. Computer Science geeks can check their attitude at the door.

class Program
        static void Main(string[] args)

            InteractService _svc = new InteractService();
            //define the URI for the interact service listening for requests
            _svc.Url = "http://localhost:7001/interact/services/InteractService";

            //this will validate that we connect successfully upon receiving a version
            //number from the service
            getVersionResponse rVersion = _svc.getVersion();

            //setup the name-value pair(s) specifying the audience
            NameValuePairImpl IndivId = new NameValuePairImpl();
            IndivId.name = "Indiv_Id";
            IndivId.valueAsNumeric = 948;
            IndivId.valueDataType = "numeric";
            NameValuePairImpl[] initAudience = { IndivId };

            //setup the expected record structure for the session
            //these values don't have to have values, but the structure must
            //be defined!
            List<NameValuePairImpl> parmList = new List<NameValuePairImpl>();
            InteractHelper hlpr = new InteractHelper();
            parmList.Add(hlpr.defineParm("Score", 250));
            parmList.Add(hlpr.defineParm("HHold_Id", 372));
            parmList.Add(hlpr.defineParm("Head_Of_Hhold", "1"));
            parmList.Add(hlpr.defineParm("Score_Date", DateTime.Now));
            parmList.Add(hlpr.defineParm("Score", 300));
            parmList.Add(hlpr.defineParm("Marital_Status", "Single"));
            NameValuePairImpl[] sessionParms = parmList.ToArray();

            //start the interact session
            Response r = _svc.startSession("123456", false, true, "Insurance", initAudience, "Individual",

            //get available offers for the session
            Response rOffersAvail = _svc.getOffers(r.sessionID, "OnLineInsuranceHomePage", 5);

            //end the program


There are a few things that are important to review. These are represented in the images below.

First, the record structure defined within the Interact session should be in sync with the name-value pair array submitted when initiating an Interact session. This is shown in the image below while using my helper class for defining the Name-Value pair array.

Second, the offers received as part of the session match against the offer rules defined as part of the campaign for the given interaction zone. All offer rules from other campaigns are applied, such as expiration dates rendering an offer invalid. In the example below, I’m showing the program running in debug mode while watching variable assignment. Note that two offers are returned when making the getOffers() request for an individual with a FICO of 300 (aka. segment=MedFICO). The offers suggested are both active across all zones. The other two defined across the zones have both reached their expiration date. As a result, they are not returned.

And that is it. If you haven’t fallen asleep by now, congrats you made it. Hope it helps as you learn Interact. There are some tricky bits that make the getting started process bumpy. This post with the code samples should help you get going faster.

Create a free website or blog at WordPress.com.