Configuring Adobe Analytics and Acoustic Exchange

As a part of Acoustic Personalization integration with your Single-Page Application (SPA) or Multi-Page Application (MPA), you must configure a tagging and analytics engine such as Adobe Analytics.

Attention: Adobe will sunset Dynamic Tag Management (DTM) in the near future. As a part of this process, new Web properties cannot be created in DTM. The procedure described in this topic can only be used if you already have a Web property created in DTM.

Prerequisites

Ensure that the following prerequisites are fulfilled.
  1. Web property is available in Adobe DTM.
  2. The Production Embed Code snippet of the Web property is added to your channel web pages.
  3. A tool is added for the Web property.
  4. Adobe Analytics is registered as an endpoint in Acoustic Exchange. For more information, see Registering tagging libraries in Acoustic Exchange
  5. Your channel is using Acoustic Personalization Library version < 1.2.0.

Step 1: Get the Acoustic Exchange Capture Enablement Key

  1. In Acoustic Exchange, navigate to Acoustic Exchange Capture from the Tools menu.
  2. Click Enablement Key icon, and copy the following lines of code that contain the enablement key and paste them in a notepad file. These lines of code will be required in Step 2.
    
    <script type="text/javascript" src="//commercelibs.ibm.com/common/ubxCapture.js"> </script>
    <script type="text/javascript"> ubxCapture.setID("<<UBX Capture Enablement Key>>"); 
    </script>
    

Step 2: Create new rule

Log in to Adobe Analytics Dashboard and perform this step onwards.
Adding Acoustic Exchange Enablement Key
  1. In the Adobe Analytics Dashboard, click the Web property that you created in the prerequisites.
  2. Go to Rules > Page Load Rules
  3. Click Create New Rule button.
  4. Provide a name for the rule.
  5. In the Conditions, select Trigger rule at: Top of Page
  6. Go to JavaScript / Third-Party Tags tab.
  7. Select the Sequential HTML option.
  8. Click Add new script button.
    • Provide a name for the tag.
    • Select Type: Sequential HTML
    • Add the Acoustic Exchange enablement key code that you copied in Step 1.
      
      <script type="text/javascript" src="//commercelibs.ibm.com/common/ubxCapture.js"> </script>
      <script> var channelID ="<<channel tenant ID>>"; 
      ubxCapture.setTenantID("WRTP",channelID); 
      ubxCapture.setTenantID("AA","<<UBX Events only authentication key for Adobe Analytics Endpoint>>");
      </script> 
      <script type="text/javascript"> ubxCapture.setID("<<UBX Capture Enablement Key>>");
      </script>
      
      • The highlighted lines of code do not exist in the enablement key and should be added manually.
      • Replace the string <<channel tenant ID>> with the channel tenant ID of your channel.
      • The variable channelID specified here must be the same as the value for Path attribute of Data element that you will create in Step 3.
      • For more information about <<UBX Events only authentication key for Adobe Analytics Endpoint>>, see the section "Configure tagging and analytics library in UBX Capture" in the topic Configuring Acoustic Personalization in UBX Capture
  9. Click Save. Next, click Save Rule.

The new rule is displayed in Page Load Rules tab.

Adding personalization script
Similarly, create another new rule for the Web property with the following parameters.
  1. Click Create New Rule button.
  2. Provide a name for the rule.
  3. In the Conditions, select Trigger rule at: Onload
  4. Click JavaScript / Third-Party Tags tab.
  5. Click Add new script button. 
  6. Provide a name for the tag. 
  7. Select Sequential JavaScript
  8. Select the Execute Globally check box.
  9. Add the following code snippet.

    For Multi-Page Application (MPA), add the following code snippet.
    
    var ubxEvents = []; 
    var identifiersMapper = [];    
    var attributesMapper = [];
    ibm_ubx.registerCallback("WRTP", function (eventPayload){
           if (eventPayload) 
                {
                   ubxEvents.push(eventPayload);
                }
    });
    //Personalization 
    if (wrtp != undefined || wrtp != {}) {
                    const WRTP = wrtp.ole.JsWRTP.create();
    
                    const zoneId = "<<ZoneID of the zone registered for personalization>>";
    
                    WRTP.getContentId(zoneId)
                        .then((contentId) => {
                            let zoneArea = WRTP.getZoneArea(zoneId);
                            if (contentId !== 'DCIDNF404') {
                                if (zoneArea) {
                                    //Add code to render personalized content
                                    zoneArea.style.opacity = 1;
                                } else {
                                    console.log("WRTP: ${zoneId} personalized and not displayed");
                                }
                            } else {
                                if (zoneArea) {
                                   //Add code to render default content
                                    zoneArea.style.opacity = 1;
                                } else {
                                    console.log("WRTP: ${zoneId} not personalized and not displayed");
                                }
                            }
                        })
                        .catch((error) => {
                            console.log("WRTP: Error occurred during zone personalization");
                        });
          } else {
                    console.log("WRTP: Error in loading the online-engine library.");
          }
    
    • In the code snippet, replace the text <<ZoneID>> with the registered zone ID.
    • This code snippet is for a single zone. For multiple zones, see the example code snippet in the topic Configuring the zones on MPA
    For Single-Page Application (SPA), add the following code snippet.
    
     var ubxEvents = []; 
     var identifiersMapper = [];    
     var attributesMapper = [];
     ibm_ubx.registerCallback("WRTP", function (eventPayload){
           if (eventPayload) 
                {
                   ubxEvents.push(eventPayload);
                }
     });
    
    Next, add the personalization code for SPA, as described in the topic Configuring the zones of Angular SPA
  10. Click Save.
  11. Click Save Rule.

Step 3: Creating Data elements

Perform the following steps to create a Data Element to send the Channel Tenant with each Adobe Analytics event.
  1. Go to Data Elements tab.
  2. Click Create New Data Element.
    • In the Name field, enter the name for Channel Tenant ID. For example, Channel Tenant ID
    • Select Type: JS Object
    • In the Path field, enter: channelID
      • The Path value must be the same as the variable provided in the code snippet of Step 2. In this case, the value is channelID.
    • Select Default Value as: - (blank)
    • Select Remember this value for: Session
  3. Click Save.

Step 4: Configure events

Perform the following steps to modify the Adobe Analytics events and add the Data Element to send the Channel Tenant with each of the events to Acoustic Exchange.
  1. Go to Event Based Rules tab.
  2. Click Create New Rule.
    • In the Name field, provide the name event name, for example ProductView.
    • Go to Conditions > Event, select Event type: Click
  3. In the Element Tag or Selector text box under Tag section, enter the ID and class of the HTML element (for example, a button) for which you want to capture the event.
  4. Go to Adobe Analytics
    • Select s.tl(); - does NOT increment a pageview
    • Select Link Tracking: Custom Link
    • Provide a name in the Link Name field.
  5. Go to eVars section.
  6. Select a name for the eVar. For example: evar1
  7. In the Set as type %. A list of data elements appears. Select a data element. For example, %Channel Tenant ID%
  8. Click Save eVar.
  9. Go to Props section.
  10. Select a name for the Prop. For example: prop1
  11. In the Set as field, type %. A list of data elements appears. Select a data element. For example, %Channel Tenant ID%
  12. Click Save Prop.
  13. Go to JavaScript/Third-Party Tag tab.
  14. Select Sequential JavaScript .
  15. Click Add New Script button.
    • Provide a name for the tag.
    • Select Type as Sequential JavaScript
    • Important! Ensure that Execute Globally check box is clear.
    • Add the following code snippet. This is an example snippet for ProductView event.
      
      attributesMapper.push({ "adobeName": "prop1", "ubxName": "channeltenantId", "type": "string" }) 
      adobe_ubx.sendEventFromJSONPayload(s, identifiersMapper, "ibmproductView", attributesMapper);
      
  16. Similarly, add the highlighted line of code for all the events.

    For more information about Adobe Analytics events, see Subscribing to Adobe Analytics events in Acoustic Exchange

  17. Save the rule.

Step 5: Approve and Publish the rules

To approve the rules, complete the following steps.
  1. Go to Approvals tab.
  2. Click Approve for all the rules.
To publish the approved rules, complete the following steps.
  1. Go to Overview tab.
  2. Click Publish Queue button.
  3. Click Publish Selected button.

References

For detailed information about configuring Adobe Analytics with Acoustic Exchange, see this IBM Knowledge Center documentation.