Context Driven
Context Driven
Context Driven
PUBLIC
Warning
This document has been generated from the SAP Help Portal and is an incomplete version of the official SAP product documentation. The
information included in custom documentation may not re ect the arrangement of topics in the SAP Help Portal, and may be missing
important aspects and/or correlations to other topics. For this reason, it is not for productive use.
Pro leservices
Click streams and order events are an important part of customer interactions. The following set of extensions enable capturing and
processing such click and order events in Context-Driven Services Foundation. The Context-Driven Services Foundation integration allows
the following events to be sent to Context-Driven Services Foundation:
User events
Registration
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c4… 2/18
3/5/2020
Login
Page View
Product View
Category View
Keyword search
Add to cart
Change quantity
Withdraw consent
Closed account
Order events
Order creation
See the following sections for more information and related functionality:
For installation information, see Installing Context-Driven Services Foundation Integration with B2C Accelerator.
For information about other libraries and sub-systems that Context-Driven Services Foundation relies on, see Pro leservices.
For information on how to easily tag websites and capture data that describe customer behavior, see Pro le Tag AddOn.
For an explanation on how the Context-Driven Pro le integration handles consents, see Consent Management.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c4… 3/18
3/5/2020
ChangedUIEvent: Triggered when the user updates a user identi er eld, such as email address.
SubmitOrderEvent
ConsignmentProcessingEvent
CreateReturnEvent
The following diagram shows the data ow associated with these order management events.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c4… 4/18
3/5/2020
The profileservices extension also detects when a user registers or logs in. In response, the extension sends a registration or login
event to Context-Driven Services Foundation. The following diagram shows the data ow related to registration and login events.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c4… 5/18
3/5/2020
Related Information
Event System
Dynamic Process De nitions
Pro leservices
Installing Context-Driven Services Foundation Integration with B2C Accelerator
Order Management Services Module
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c4… 6/18
3/5/2020
Dependencies
Dependencies Diagram
Recipes
There are currently no recipes that include the Context-Driven Services Foundation Integration module.
Extensions
Context-Driven Services Foundation consists of the following extensions:
Pro leservices
The profileservices extension listens to the following events and submits the included data to Context-Driven Services
Foundation.
Pro le Tag AddOn
Tracking consumers on web pages requires capturing data while consumers browse the site. You can usually accomplish this with a
tracking pixel, or tag: code inserted into a web page that sends data to the server. In the past, tracking pixels were transparent GIF
images. Now, tracking pixels are more sophisticated tags based on JavaScript.
Pro leservices
The profileservices extension listens to the following events and submits the included data to Context-Driven Services Foundation.
SubmitOrderEvent
ConsignmentProcessingEvent
CreateReturnEvent
It also detects when users register or log in and sends both events to Context-Driven Services Foundation.
Directory
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c4… 7/18
3/5/2020
hybris/bin/modules/cds-integration
It is cumbersome to manually create and maintain such tags throughout a website. Context-Driven Pro le Tag simpli es tag management
and data capture. Using the easy-to-use user interface, you con gure the way data gets sent to Context-Driven Services Foundation.
Context-Driven Services Foundation offers a exible way to adapt to the structure of your online presence, and allows you to de ne the
events that you create by sending the information you wish to store in Context-Driven Services Foundation.
The Pro le Tag AddOn provides an easy path for users of the B2C accelerator to tag the website and send events to Context-Driven
Services Foundation.
Market Yes No No
CMS Components
This AddOn adds the following CMS components:
ImpEx
The new CMS components are imported into the Commerce Accelerator with the following ImpEx script.
Note
The script is found in the hybris/bin/modules/sec-customer-
service/secaddon/resources/secaddon/import/contentCatalogs/electronicsContentCatalog/cms-
responsive-content.impex le
$contentCatalog=electronicsContentCatalog
$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version
$jarResourceCms=jar:com.hybris.yprofile.profiletagaddon.constants.ProfiletagaddonConstants&/profiletagaddon/
$siteUid=electronics
$lang=en
INSERT_UPDATE ConsentTemplate;id[unique=true];name[lang=$lang];description[lang=$lang];version[unique=true];
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c4… 8/18
3/5/2020
;PROFILE;"Allow SAP Commerce Cloud, Context-Driven Services tracking";"We would like to store your browsing
INSERT_UPDATE ProfileTagScriptComponent;$contentCV[unique=true];uid[unique=true];name;
;;ProfileTagScriptComponent;Profile Tag;ProfileTagScriptTagScript;;
INSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];active;cmsComponents(uid,$contentCV)[mode
;;PlaceholderContentSlot;true;ProfileTagScriptComponent
The profileTagAddonBeforeViewHandler
The profileTagAddonBeforeViewHandler gets executed every time before the view is rendered.
TheprofileTagAddonBeforeViewHandler is responsible for reading the values in the Con guration, and sets these key-values as
model attributes.
Installation
For instructions on installing Context-Driven Services Foundation integration and Pro le Tag AddOn, see Installing Context-Driven
Services Foundation Integration with B2C Accelerator.
Modi cations
The AddOn modi es the Accelerator's ImpEx Con guration Scripts, CMS Components, and JavaScript.
Removing the consent cookie for the storefront prevents merging of the pro les for different users using the same browser on the same
computer. To remove the consent reference cookie, perform the following steps:
RemoveConsentCookieLogoutHandler Class
package de.hybris.platform.yacceleratorstorefront.security.cookie;
import de.hybris.platform.basecommerce.model.site.BaseSiteModel;
import de.hybris.platform.site.BaseSiteService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.web.util.CookieGenerator;
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c4… 9/18
3/5/2020
final BaseSiteService baseSiteService)
{
this.cookieGenerator = cookieGenerator;
this.consentReferenceCookieNameSuffix = consentReferenceCookieNameSuffix;
this.baseSiteService = baseSiteService;
}
@Override
public void logout(final HttpServletRequest request, final HttpServletResponse response, final Aut
{
final BaseSiteModel baseSite = baseSiteService.getCurrentBaseSite();
if (baseSite.getUid() != null)
{
final String cookieName = baseSite.getUid() + consentReferenceCookieNameSuffix;
cookieGenerator.setCookieName(cookieName);
cookieGenerator.removeCookie(response);
}
}
}
2. De ne the bean for RemoveConsentCookieLogoutHandler and add it to the list of handlers for the logoutFilter.
Remember to add it before the SecurityContextLogoutHandler.
hybris/bin/modules/platform/samlsinglesignon/web/webroot/WEB-INF/security/spring-security-con g.xml
For details on consent management for Context-Driven Services Foundation, see Consent Management.
Consent Management
The Context-Driven Services Foundation integration uses Consent Management to handle consents.
Installing Context-Driven Services Foundation Integration with B2C Accelerator
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c… 10/18
3/5/2020
The Context-Driven Services Foundation integration can be installed with Commerce B2C Accelerator for a development
environment or for demonstration purposes.
Consent Management
The Context-Driven Services Foundation integration uses Consent Management to handle consents.
By default, one template is available in the Pro le Tag AddOn sample data: PROFILE. Here is an example of the properties of the default
template in an electronics storefront.
Note
The Java properties of the model class are used as column headers, and not the actual database column headers.
When a user gives or withdraws consent, the system res ConsentGivenEvent and ConsentWithdrawn. The profileservices
extension reacts to these events and sends a DELETE request to the Consent Service in Context-Driven Services Foundation, which
triggers the deletion of the customer's data. For more details, see the Consent Management section in Context-Driven Services
Foundation Security.
You must de ne the consent template with the ID PROFILE for any other custom website.
$siteUid=customSiteId
$lang=en
INSERT_UPDATE ConsentTemplate;id[unique=true];name[lang=$lang];description[lang=$lang];version[unique=true];
;PROFILE;"Allow SAP Commerce Cloud, Context-Driven Services tracking";"We would like to store your browsing
To install Context-Driven Services Foundation Integration with B2C Accelerator, choose one of these methods:
Use the installer. For more details, see Installing the Context-Driven Services Foundation Integration Using the Installer.
Install manually. For more details, see Manually Installing the Context-Driven Services Foundation Integration.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c… 11/18
3/5/2020
Prerequisites
Before you begin, you will need a local_property:initialpassword.admin=password.
Procedure
Execute the following commands from the installer subfolder.
For more information, see Installing SAP Commerce Using Installer Recipes.
Procedure
1. Add the following extensions to localextensions.xml.
...
<extension name='profiletagaddon' /><!--has to be installed on the b2c storefront-->
<extension name='profileservices' />
...
This command generates the correct properties in the project.properties le of the profiletagaddon add-on. It also
adds a dependency from your storefront to the profiletagaddon add-on.
3. Start the SAP Commerce Server and proceed to update or initialize the running system.
4. If you do not or cannot load the project data, execute one of the the following impex les manually.
hybris/bin/modules/sap-customer-activity-repository/sappostransactionaddon/resources/sappostransa
hybris/bin/modules/sap-customer-activity-repository/sappostransactionaddon/resources/sappostransa
hybris/bin/modules/sap-customer-activity-repository/sappostransactionaddon/resources/sappostransa
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c… 12/18
3/5/2020
$contentCatalog=YOUR-CONTENT-CATALOG
$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVers
$jarResourceCms=jar:com.hybris.yprofile.profiletagaddon.constants.ProfiletagaddonConstants&/profi
$siteUid=YOUR-SITE-UID
$lang=en
INSERT_UPDATE ConsentTemplate;id[unique=true];name[lang=$lang];description[lang=$lang];version[un
;PROFILE;"Allow SAP Hybris Profile tracking";"We would like to store your browsing behaviour so t
INSERT_UPDATE ProfileTagScriptComponent;$contentCV[unique=true];uid[unique=true];name;
;;ProfileTagScriptComponent;Profile Tag;ProfileTagScriptTagScript;;
INSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];active;cmsComponents(uid,$cont
;;PlaceholderContentSlot;true;ProfileTagScriptComponent
Procedure
1. Set up a Client in the Context-Driven Services.
2. Add the Context-Driven Services Foundation con guration to SAP Commerce using ImpEx.
Setting up a Client
You need to set up a client to use with your Context-Driven Services Foundation Integration.
Procedure
1. Sign in to the Context-Driven Services.
3. Click + CLIENT .
Note
The Client ID must begin with a lowercase letter (a-z) and must be 2-47 characters long. It can contain lowercase letters
(a-z), numbers (0-9), and dashes (except at the end of the name).
Note
To provide successful communication between the module functionality and the cloud platform, select the Commerce
Cloud integration client role.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c… 13/18
3/5/2020
5. Click ADD .
A pop-up window with the client details appears. It displays all information you entered in the previous step, and additionally
provides you with the client secret.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c… 14/18
3/5/2020
Caution
Save your client secret before closing the pop-up window, or else it will be lost. Client secret retrieval is impossible. If the system
forgets your client secret, you can only reset it or generate a new one.
Context
The following procedure uses the example values shown in the prerequisites.
Procedure
1. In the SAP Commerce Administration Console, go to Console ImpEx Import .
$client = <the ID of your SAP Commerce client which you created in CDS lounge. Use your clientId witho
$clientsecret = <the secret you got for this client in CDS lounge>
$region = <the region in which this tenant is created, e.g. US or EU>
$projectid = <the tenant ID, e.g. htv730339940>
$profiletagconfigurl = <the URL of your Profile Tag configuration JSON, e.g. https://tag.static.us.con
$basesite = <the site within your SAP Commerce instance, which shall be configured for CDS, e.g. "elec
INSERT_UPDATE DestinationTarget;id[unique=true];destinationChannel(code)[default=CDS]
;$projectid;CDS
INSERT_UPDATE ConsumedOAuthCredential;id[unique=true];clientId;clientSecret;oAuthUrl
;$projectid.$client;$projectid.$client;$clientsecret;$oauthservice
INSERT_UPDATE Endpoint;id[unique=true];version[unique=true];specUrl;name
;ProfileClient;v1;"empty";"Profile Client v1"
;ConsentServiceClient;v1;"empty";"Consent Service Client v1"
;ProfileTagUrl;v1;"empty";"Profile Tag Url v1"
;ProfileTagConfigUrl;v1;"empty";"Profile Tag Config Url v1"
INSERT_UPDATE ConsumedDestination;id[unique=true];url;additionalProperties(key,value)[map-delimiter=|]
;ProfileClient$basesite;$edgeservice;baseSite->$basesite|clientClassName->ProfileClient;ProfileClient;
;ConsentServiceClient$basesite;$consentservice;baseSite->$basesite|oauth.scope->cds.roles.customerec|c
;ProfileTagUrl$basesite;$profiletagurl;baseSite->$basesite|clientClassName->ProfileTagUrl;ProfileTagUr
;ProfileTagConfigUrl$basesite;$profiletagconfigurl;baseSite->$basesite|clientClassName->ProfileTagConf
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c… 15/18
3/5/2020
$client Your client with the Commerce Cloud integration Used for authentication purposes.
client role.
$clientSecret The client secret created with the scopes for Context-Driven Used for authentication purposes.
Services Foundation.
$projectId The ID of your tenant, usually starting with htp or htv. Used for authentication purposes.
$profiletagconfigurl The URL of your Pro le Tag con guration JSON. Used for enabling the Pro le Tag feature.
$baseSite The ID of your SAP Commerce base site, such as apparel-uk. Used for mapping a tenant to a base site.
Procedure
1. Go to your storefront, for example, https://localhost:9002/yacceleratorstorefront?site=electronics.
This is an example of a default storefront. You may have con gured your own storefront, so be sure to use the correct link.
2. Add the query parameter profileTagDebug=true to the URL to get a more verbose console logging.
4. To capture the consent reference that identi es your pro le, perform the following actions:
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c… 16/18
3/5/2020
b. Select Development from the menu.
6. Fill out the Pro le Id eld with the consent-reference copied in the previous step and click the search button.
You can track the events sent from the storefront to Context-Driven Services Foundation in the Trace Explorer.
To enable tracing in your storefront, use Pro le Tag in the debug mode. Activate the pro le Tag debug mode by adding the
pro leTagDebug ag to your storefront URL and setting its value to true. A sample storefront's URL
https://electronics.local:9002/yacceleratorstorefront with the debug ag looks as follows:
https://electronics.local:9002/yacceleratorstorefront?profileTagDebug=true.
To navigate to the Trace Explorer, click the contextTraceId link that appears at the top of the screen each time the storefront sends an
event to Context-Driven Services Foundation. In the Trace Explorer, you can nd the logs containing the details of event processing, such
as the information about the changes that your events introduce to the pro le document.
When the debug mode is enabled, Pro le Tag AddOn prints the contextTraceId in the development console of the browser. For the
backend events, the contextTraceIds are printed in SAP Commerce. For example:
Code Syntax
{HYBRIS_HOME_DIR}/log/tomcat/console-YYYYMMDD.log
To disable debug mode, add the pro leTagDebug ag to your storefront URL and set its value to false.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c… 17/18
3/5/2020
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=21802335&topics=60a3ba003ad8465cb9c22a0b7c… 18/18