The body Section (start)
Add the following code immediately following the <body> tag to add the client context features to the page:
<cq:include path="clientcontext" resourceType="cq/personalization/components/clientcontext"/>
The body Section (end)
Add the following code immediately before the </body> end tag:
<cq:include path="cloudservices" resourceType="cq/cloudserviceconfigs/components/servicecomponents"/>
The JSP script of this component generates calls to the Target javascript API and implements other required configurations. The HTML that the script generates is similar to the following example:
<div class="servicecomponents cloudservices">
<div class="cloudservice testandtarget">
<script type="text/javascript">
CQ_Analytics.TestTarget.maxProfileParams = 11;
CQ_Analytics.CCM.addListener("storesinitialize", function(e) {
CQ_Analytics.TestTarget.registerMboxUpdateCalls();
});
</script>
<div id="cq-analytics-texthint" style="background:white; padding:0 10px; display:none;">
<h3 class="cq-texthint-placeholder">Component clientcontext is missing or misplaced.</h3>
</div>
<script type="text/javascript">
$CQ(function(){
if( CQ_Analytics &&
CQ_Analytics.ClientContextMgr &&
!CQ_Analytics.ClientContextMgr.isConfigLoaded )
{
$CQ("#cq-analytics-texthint").show();
}
});
</script>
</div>
</div>
Using a Custom Target library file
The default mbox.js file that is used to create mboxes is located at /etc/clientlibs/foundation/testandtarget/mbox/source/mbox.js. To use a customer mbox.js file, add the file to the Target cloud configuration. To add the file, the mbox.js file must be available on the file system.
For example, if you want to use the Marketing Cloud ID service you need to download mbox.js so that it contains the correct value for the imsOrgID
variable, which is based on your tenant. This variable is required for integrating with the Marketing Cloud ID service. For information, see Adobe Analytics as the Reporting Source for Adobe Target and Before You Implement.
- Go to the CQ Tools page and select Cloud Services. (https://localhost:4502/libs/cq/core/content/tools/cloudservices.html)
- In the tree, select Adobe Target, and in the list of configurations, double-click your Target configuration.
- On the configuration page, click Edit.
- For the Custom mbox.js property, click Browse and select the file.
- To apply the changes, enter the password for your Adobe Target account, click Re-connect To Target, and click OK when the connection is successful. Then, click OK on the Edit Component dialog box.
Your Target configuration includes a custom mbox.js file, the required code in the head section of your page adds the file to the client library framework instead of a reference to the testandtarget.js library.
Disabling the Target Command for Components
Most components can be converted to targeted components using the Target command on the context menu.
To remove the Target command from the context menu, add the following property to the cq:editConfig node of the component:
- Name: cq:disableTargeting
- Type: Boolean
- Value: True
For example, to disable targeting for the title components of the Geometrixx Demo Site pages, add the property to the /apps/geometrixx/components/title/cq:editConfig node.
Sending Order Confirmation Information to Adobe Target
For tracking the performance of your website, send purchase information from your order confirmation page to Adobe Target. (See Create an orderConfirmPage Mbox and Order Confirmation Mbox - Add custom parameters.) Adobe Target recognizes mbox data as order confirmation data when your MBox name is orderConfirmPage
and uses the following specific parameter names:
- productPurchasedId: A list of IDs that identify the purchased products.
- orderId: The ID of the order.
- orderTotal: The total amount of the purchase.
The code on the rendered HTML page that creates the mbox is similar to the following example:
<script type="text/javascript">
mboxCreate('orderConfirmPage',
'productPurchasedId=product1 product2 product3',
'orderId=order1234',
'orderTotal=24.54');
</script>
The values of each parameter are different for each order. Therefore, you require a component that generates the code based on the properties of the purchase. The CQ eCommerce Integration Framework enables you to integrate with your product catalogue and implement a shopping cart and checkout page.
The Geometrixx Outdoors sample displays the following confirmation page when a visitor purchases products:
The following code for the JSP script of a component accesses the properties of the shopping cart and then prints the code for creating the mbox.
<%--
confirmationmbox component.
--%><%
%><%@include file="/libs/foundation/global.jsp"%><%
%><%@page session="false"
import="com.adobe.cq.commerce.api.CommerceService,
com.adobe.cq.commerce.api.CommerceSession,
com.adobe.cq.commerce.common.PriceFilter,
com.adobe.cq.commerce.api.Product,
java.util.List, java.util.Iterator"%><%
/* obtain the CommerceSession object */
CommerceService commerceservice = resource.adaptTo(CommerceService.class);
CommerceSession session = commerceservice.login(slingRequest, slingResponse);
/* obtain the cart items */
List<CommerceSession.CartEntry> entries = session.getCartEntries();
Iterator<CommerceSession.CartEntry> cartiterator = entries.iterator();
/* iterate the items and get the product IDs */
String productIDs = new String();
while(cartiterator.hasNext()){
CommerceSession.CartEntry entry = cartiterator.next();
productIDs = productIDs + entry.getProduct().getSKU();
if (cartiterator.hasNext()) productIDs = productIDs + ", ";
}
/* get the cart price and orderID */
String total = session.getCartPrice(new PriceFilter("CART", "PRE_TAX"));
String orderID = session.getOrderId();
%><div class="mboxDefault"></div>
<script type="text/javascript">
mboxCreate('orderConfirmPage',
'productPurchasedId=<%= productIDs %>',
'orderId=<%= orderID %>',
'orderTotal=<%= total %>');
</script>
When the component is included in the checkout page in the previous example, the page source includes the following script that creates the mbox:
<div class="mboxDefault"></div>
<script type="text/javascript">
mboxCreate('orderConfirmPage',
'productPurchasedId=47638-S, 46587',
'orderId=d03cb015-c30f-4bae-ab12-1d62b4d105ca',
'orderTotal=US$677.00');
</script>
Understanding the Target Component
The Target component enables authors to create dynamic mboxes from CQ content components. (See Content Targeting.) The Target component is located at /libs/cq/personalization/components/target.
The target.jsp script accesses the page properties to determine the targeting engine to use for the component, and then executes the appropriate script:
- Adobe Target: /libs/cq/personalization/components/target/engine_tnt.jsp
- Adobe Target with AT.JS: /libs/cq/personalization/components/target/engine_atjs.jsp
- Adobe Campaign: /libs/cq/personalization/components/target/engine_cq_campaign.jsp
- Client-side Rules/ContextHub: /libs/cq/personalization/components/target/engine_cq.jsp
The Creation of Mboxes
When Adobe Target drives content targeting, the engine_tnt.jsp script creates mboxes that contain the content of the targeted experience:
-
Adds a
div
element with the class ofmboxDefault
, as required by the Adobe Target API. -
Adds the mbox content (the content of the targeted experience) inside the
div
element.
Following the mboxDefault
div element, the javascript that creates the mbox is inserted:
- The mbox name, ID, and location are based on the repository path of the component.
- The script obtains Client Context parameter names and values.
- Calls are made to the functions that mbox.js and other client libraries define to create mboxes.
Client Libraries for Content Targeting
The following are the available clientlib categories:
- testandtarget.mbox
- testandtarget.init
- testandtarget.util
- testandtarget.atjs
- testandtarget.atjs-integration
Experience Manager
Put the Customer at the Center and Build Relationships That Last a Lifetime
First impressions last a lifetime. Great first impressions feel personal, connected, and relevant right from the start. From the first...
Wed, Mar 19, 2:30 PM PDT (9:30 PM UTC)
Elevate and Empower Teams with Agentic AI for Exceptional Experiences
Elevate and empower your CX teams with AI that transforms creativity, personalization, and productivity. Discover how Adobe is...
Tue, Mar 18, 1:00 PM PDT (8:00 PM UTC)
Connect with Experience League at Summit!
Get front-row access to top sessions, hands-on activities, and networking—wherever you are!
Learn more