Configure DA with Exchange

In order to achieve personalization, the analytics library deployed on your channel should send the visitor behavior data and channel events data to Acoustic Exchange.

If you use Acoustic Digital Analytics as the analytics library for your Single-Page Application (SPA) or Multi-Page Application (MPA), use this topic to configure it to interact with Acoustic Exchange.

Prerequisites

  • You must have Digital Analytics configured on the channel to be personalized.
  • You must have an Acoustic Digital Analytics ID (known as the client ID) specific to the channel to be personalized.
    To view your client ID, perform the following steps:
  1. Log in to your Digital Analytics application.
  2. From the primary navigation menu, you can view your current client ID within the Optimize sub-menu.

📘

The DA ID must be numeric and should not contain any alphabets or special characters such as "|"
For example: 30001001 is a valid DA ID, whereas 30001001|RTP is not valid.

  • You should have the channel tenant ID that was generated when you registered the channel with Acoustic Personalization.

After you've completed these prerequisites, let's get started with configuring your DA library with Exchange.

Step 1. Add the Exchange Capture Enablement code

  1. Log in to Acoustic Exchange, and using the menu, navigate to Tools > Exchange Capture.
176
  1. Click the Enablement Code icon.
289
  1. Copy the two lines of code that contain the enablement code. Save these lines of code in a text editor. These lines will be required in the next step.
629
  1. Click Close.
  2. Paste the two lines you'd copied to your channel code.
  • If your channel is an SPA, paste these two lines at the beginning of HEAD tag of your index.html.
  • If your channel is an MPA, paste these two lines at the beginning of HEAD tag of each HTML page.
  1. Before the setID function, add the following lines of code. This ensures that the correct pairing of your Personalization endpoint and Digital Analytics endpoint is used in Exchange, by specifying the channel ID and the DA ID.
<script> ubxCapture.setTenantID("WRTP","<<channel_tenant_ID>>");
               ubxCapture.setTenantID("DA","<<DA_ID>>");
</script>

Now the overall Exchange code snippet looks similar to the one shown here.

<script type="text/javascript" src="//lib-us-3.brilliantcollector.com/common/ubxCapture.js">
  //Line from Exchange Capture enablement code
  </script>
<script> ubxCapture.setTenantID("WRTP","<<channel_tenant_ ID>>");
               ubxCapture.setTenantID("DA","<<DA_ID>>");
//SetTenantID must always be called before setID
</script>
<script type="text/javascript"> ubxCapture.setID("<<UBX_Capture_Enablement_Key>>"); 
//Line from Exchange Capture enablement code
</script>

📘

Ensure that the setTenantID script is always called before the setID script.

Step 2. Add the DA tracking code

Add the code snippet that enables Digital Analytics to track the visitor behavior on your channel and share the events information with Exchange.

  • In case of Single-Page Application, add the following code at the beginning of HEAD tag of index.html page.
  • In case of Multi-Page Application, add the following code at the beginning of HEAD tag of each HTML page.

📘

If Acoustic Digital Analytics is already configured for your channel, the following code would already be present in your channel page and only needs to be updated as required. Add the code if it is not present in your channel pages.

<script>
  //Initialize the variables
         var channelID = "<<Channel Tenant ID>>";
         var DA_Id = "<<DA ID>>"; 
         var ubxEvents = [];		
         var identifiersMapperArray = [];   
</script>  
<script type="text/javascript" src="//lib-us-3.brilliantcollector.com/common/ubxCapture.js">
  //Line from Exchange Capture enablement code
  </script>
<script> ubxCapture.setTenantID("WRTP","<<channel tenant ID>>");
               ubxCapture.setTenantID("DA","<<DA ID>>");
//SetTenantID must always be called before setID
</script>
<script type="text/javascript"> ubxCapture.setID("<<UBX Capture Enablement Key>>"); 
//Line from Exchange Capture enablement code
</script>
<script>
//Start of Digital Analytics Tracking snippet
          var retriesCallBack = 1500;
        var registerCallbackFlag = false , cmpartnerUtilsFlag = false;
        var timerHandleCallback = setInterval(function() {
            if(!cmpartnerUtilsFlag  && typeof _cmPartnerUtils != 'undefined' && typeof _cmPartnerUtils == 'object'){
                try{
                    cm_ATEnabled = true;
                    _cmPartnerUtils.setContactRule({
                        cid: DA_Id,
                        version: 1,
                        partners: [{
                        pid: 9999,
                        type: 'S',
                        url: 'https://cdn-personalization-us-1.goacoustic.com/acoustic/prod/pznda/pzn2da.js',
                        surl: 'https://cdn-personalization-us-1.goacoustic.com/acoustic/prod/pznda/pzn2da.js',
                        key: 'WRTP'
                        }],
                        tags: [ 
                            [1, 2, 3, 4, 5, 6, 7, 8, 14, 15]
                        ],
                        segmentRules: [],
                        segments: [],
                        usesNewRepeat: false
                    });
                    cmpartnerUtilsFlag = true
                }catch(e){}
                
            } 
            if(!registerCallbackFlag && typeof ibm_ubx.registerCallback != undefined && typeof ibm_ubx.registerCallback == 'function'){
                try{
                    ibm_ubx.registerCallback("WRTP", function (eventPayload){
                        if (eventPayload){
                        ubxEvents.push(eventPayload);
                        }
                    });
                    registerCallbackFlag = true
                }catch(e){}
            }
            if((registerCallbackFlag &&  cmpartnerUtilsFlag) || retriesCallBack <= 0){
                clearInterval(timerHandleCallback);
            }
            
            retriesCallBack--;
        }, 100);       
</script>

Step 3. Configure DA events

In order to call a DA event, you need to specify the index position of channel tenant ID in the DA Extra Field Index parameter in Acoustic Exchange Capture.

  1. Log in to Acoustic Exchange, and navigate to Tools > Exchange Capture.
176
  1. From the Applications column, select your Personalization application.
556
  1. Go to DA Extra Field Index field, and specify the index position of channel tenant ID, for example "1".
800
  1. Click Save and deploy.

Now, when you call the event, you must pass the channel tenant ID at the same position that you had specified in the DA Extra Field Index field.

Example:
The following line of code calls the pageView event:

'cmCreatePageviewTag("pageId", "Category", "Search Term", "Search Result", "att1--att2--att3.....--att50", "ef1--ef2--....--ef15");'

Here, ef1 indicates Extra Field 1. Hence, if you had specified DA Extra Field Index as 1, then in this line, replace ef1 with the channel tenant ID, as shown here:

cmCreatePageviewTag(document.title, "HomePage", null, null, "att1-_-att2-_-att3", channelTenantID + "-_-ef2-_-");

Repeat this step for other events that you want to configure.

You have now successfully configured your Digital Analytics library to interact with Acoustic Exchange.

Next steps

After configuring Digital Analytics to interact with Exchange, you should Test the events flow in Exchange to verify the events flow from Digital Analytics to your Personalization application.