Configuring SAS Real-Time Decision Manager Integration

Overview

See Integrating SAS Real-Time Decision Manager for information about the added value that is provided by this functionality.

Prerequisites

You must satisfy the following prerequisites:
  • an Apache HTTP server that is configured as a clickstream collection server
  • a Web page instrumented with a SAS page tag
  • a Web page that includes the SASModRTDM.js file
  • a Web page that defines a call to the Web service either inline or with an include
  • a SAS Real-Time Decision Manager Web service that provides the appropriate response information for any requests

Configure the Web Pages

You need to add the following elements to each Web page that you want use with RTDM:
  • an anchor element
  • a SAS page tag
  • the RTDM module
  • the code to call the SAS Real-Time Decision Manager
The anchor element enables SAS page tagging to tag a link for data collection. The RTDM module modifies the anchor element and its contents appropriately with values returned by the RTDM Web service. If the RTDM Web service fails, the anchor element is displayed without modification and acts as a default value. Here is an example of an anchor element:
<a href="http://yoursite.com" id="st_rtdm_id" alt="My Advert">10% off</a>
Two script tags are required to include the RTDM functionality on a Web page. One includes the SASModRTDM.js JavaScript file that is located on the clickstream collection server, as follows:
<script language="javascript" 
type="text/javascript"src="http://ccs/sastag/SASModRTDM.js"></script> 
The second tag should include the call to the RTDM Web service. This call can be declared directly on each page or in the SASSiteConfig.js file if the call is standard across your Web site. The call to the RTDM Web service in a separate site configuration JavaScript file is included in the following example:
<script language="javascript" type="text/javascript" 
src="ccs/sastag/SASSiteConfig_site01.js"></script>
The final two script tags and one script tag enable the standard SAS page tag functionality, as shown in the following example:
<script language="javascript" type="text/javascript"
src="http://ccs/sastag/SASTag.js"></script>
<noscript>
<img src="http://ccs/sastag/SASTag.gif?JS=0 &URI=/TagsDisabled" border="0">
</noscript>
<script language="javascript" type="text/javascript">st_init();</script>

Defining the Call to the SAS Real-Time Decision Manager Web Service

An object is defined to make the call to the SAS Real-Time Decision Manager Web service. This object constructs the necessary request that is sent to the RTDM Web service. This request contains session information and then deconstructs the response to update the Web page content. The following example shows how an object might be defined:
function st_pageCfg()
{
   toRTDM = new ST_RTDM(
	{
	"event_name": "clickstream_fetch_dest",
	"url": "http://rtdm.yoursite.com/event",
	"target_element_id": "st_rtdm_id",                      // default
	"image_link_element": "CONTENT_CODE",                   // default
	"text_link_element": "CONTENT_TEXT",                    // default
	"href_element": "DEST_URL",                             // default
	"request": [["CUSTOMER_ID", "Float", global_cust_id],
	          ["PRODUCT_ID", "Int", global_product_id]],
	"capture": [[“RESPONSE_TRACKING_CODE”,”RTDMRTC],
                  ["TREATMENT_TRACKING_CODE","RTDMTTC"],
                  [“S1”,”S1”], [“S2”,”S2”],
                  [“S3”,”S3”], [“S4”,”S4”]]      // default
	}						
  );
}
Note: The default lines did not have to be specified in this example. They are included for completeness.
When inserted this code performs the following actions:
  • calls the clickstream_fetch_dest operation from the Web service located at http://rtdm.yoursite.com/event
  • internally constructs a SOAP request that contains the CUSTOMER_ID and PRODUCT_ID values. In this example the global_cust_id and global_product_id are JavaScript variables that are available from this page
  • receives a response from the Web service, pulls out the image link information from the CONTENT_CODE element and the text link information from the CONTENT_TEXT element
  • updates the anchor element in the current Web page that has the ID value of “st_rtdm_id” to display the image or text and appends the RTDMRTC, RTDMTTC and S1 to S4 query parameters to the link
  • records the RESPONSE_TRACKING_CODE and TREATMENT_TRACKING_CODE S1,S2,S3 and S4 when the image or text is clicked by the user
The parameters for the call are explained in the following tables.
The following table covers the event_name parameter:
event_name
Parameter Name
event_name
Required?
Yes
Type
String
Default
None
Description
The name of the operation to be invoked on the Web service
Example
“event_name”: “clickstream_fetch_dest”
The following table covers the url parameter:
url
Parameter Name
url
Required?
Yes
Type
String
Default
None
Description
The URL used to locate the Web service
Example
“url”: “http://comany.com/call”
The following table covers the target_element_id parameter:
target_element_id
Parameter Name
target_element_id
Required?
No (default value searched for if no value specified)
Type
String
Default
st_rtdm_id
Description
Specifies the ID attribute of the anchor element in the Web page that is to be upated as a result of the values returned from the Web service
Example
“target_element_id”: “dynamic_ad”
The following table covers the image_link_element parameter:
image_link_element
Parameter Name
image_link_element
Required?
No (default value assumed if none is specified)
Type
String (case sensitive)
Default
CONTENT_CODE
Description
Identifies the XML element in the response from the Web service that contains the text to be displayed on the current Web page
Example
“image_link_element”: “CONTENT_CODE”
The following table covers the text_link_element parameter:
text_link_element
Parameter Name
text_link_element
Required?
No (default value assumed if none is specified)
Type
String (case sensitive)
Default
CONTENT_TEXT
Description
Identifies the XML element in the response from the Web service that contains the text to be displayed on the current Web page.
The behavior associated with this parameter depends on whether the value for the element specified in the image_link_element is set or blank. If the element that contains the image_link_element is empty, the text from the text_link_element is used to create a text advertisement. If the element that contains the image_link_element has a value, this text_link_element value is set as the ALT attribute.
Example
“text_link_element”: “CONTENT_TEXT”
The following table covers the href_element parameter:
href_element
Parameter Name
href_element
Required?
No (default value assumed if none is specified)
Type
String (case sensitive)
Default
DEST_URL
Description
Identifies the XML element in the response from the Web service that contains the value to be used for the HREF attribute on the anchor element. The anchor element is identified by the target_element_id parameter.
Example
“href_element”: “DEST_URL”
The following table covers the Input parameter:
Input
Parameter Name
Input
Required?
Yes
Type
Array
Default
None
Description
Each element in this array defines a “Data” element in the generated SOAP request. Each element in the array should contain three values: the name of the XML element, its type, and finally its value.
Example
"input": [["CUSTOMER_ID", "Float", "12237"],["PRODUCT_ID", "Int", "1050"]]
<Data name="CUSTOMER_ID">
 <Float>
  <Val>12272</q0:Val>
 </Float>
 </Data>
<Data name="PRODUCT_ID">
 <Int>
  <Val>6000</q0:Val>
 </Int>
</Data>
The following table covers the capture parameter:
capture
Parameter Name
capture
Required?
No (default value assumed if none specified)
Type
Array
Default
"capture": [[“RESPONSE_TRACKING_CODE”,”RTDMRTC”],
["TREATMENT_TRACKING_CODE", "RTDMTTC"]]
Description
Each element in this array identifies the elements in the response XML whose values should be collected by the SAS Page Tagging Solution.
Each element contains two values. The first identifies the response XML element that contains the value to be collected. The second identifies the query parameter name to be used to identify this data.
Example
"capture":[["TREATMENT_CODE","RTDMTC",], 
["RESPONSE_TRACKING_CODE","RTDMRTC",],
  ["TREATMENT_TRACKING_CODE","RTDMTTC"],
 [“S1”,”S1”], [“S2”,”S2”],[“S3”,”S3”], [“S4”,”S4”]]
Would result in the following parameters being records on the clickstream collection server:
10.23.14.103 - - [02/Apr/2010:15:13:55 -0400] 
"GET /sastag/SASTag.gif?CS=ISO-8859-1$VER=2.11$EVT=
click$CID=ajax$VID=12675421017167022847841310744$URI
=http://yoursites.com/$REF=http://yoursite.com/pages
/page01.html?uname=John &product=bicycle$TTL=http:
//yoursite.com/content/saslogov1.gif$PROT=http$DOM
=yoursite.com$PORT=$PLAT=Win32$SINFO=1280x1024@24$FL
=1$FLV=10.0%20r42$CK=1$JV=1$JVV=1.6.0_18$JS=1$DT
=4/2/2010$TM=15:13:57.700$RTDMTC=WA_Click01$RTDMRTC
=983100010501$RTDMTTC=C80DBDCE9F9D813DE66D43559AD89E00$S1
=12345.0$S2=22345.0$S3=32345.0$S4=42345.0

Addressing Cross-Domain Issues

This functionality uses AJAX to communicate asynchronously with the RTDM Web service. AJAX does not allow requests to be made across different domains for security reasons. Therefore, a Web site that uses this SAS Real-Time Decision Manager integration must address these cross-domain issues. The example shown here uses the ProxyPass directive on the Apache server that serves the HTML pages to overcome the cross-domain issues. To enable this functionality, ensure that the following modules are loaded (either statically at compile time or dynamically with the LoadModule directive):
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Then add the ProxyPass and ProxyPass Reverse directives to your http.conf file, as shown in the following example:
ProxyPass /call http://specific_server_address/RTDM/Event
ProxyPassReverse /call http://specific_server_address/RTDM/Event
Please refer to the Apache HTTP Server Documentation for more information.
The URL (http://specific_server_address/RTDM/Event) specified in the ProxyPass and ProxyPassReverse statements points to your SAS Real-Time Decision Manager Web service. The “/call” value identifies the URL request that is to be forwarded to the Web service. In the ProxyPass statement above, the URL parameter of the RTDM call is defined as follows:
"url": “http://rtdm.yoursite.com/call”
The Apache HTTP server recognizes the “/call” part of the URL request and forwards the request to the RTDM Web service.