profiletagaddon AddOn

The profiletagaddon AddOn provides an easy path for users of the B2C accelerator to tag the website and send events to Intelligent Selling Services Foundation.

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.

It is cumbersome to manually create and maintain such tags throughout a website. Profile Tag simplifies tag management and data capture. Using the easy-to-use user interface, you configure the way data gets sent to Intelligent Selling Services Foundation. Intelligent Selling Services Foundation offers a flexible way to adapt to the structure of your online presence, and allows you to define the events that you create by sending the information you wish to store in Intelligent Selling Services Foundation.

SAP Commerce Cloud uses Piwik event tracking to track user actions on the website. The Piwik events are pushed into a Spring integration channel. The yprofileeventadapter extension hooks into this channel and gets the tracked data for sending to Intelligent Selling Services Foundation.

Supported Markets and Channels

The Profile Tag AddOn supports the B2C market only. It can only be used with the desktop channel.
Supported Markets and Channels
Supported B2C Commerce B2B Commerce Telco Commerce
Market Yes No No
Channel Desktop - Yes

Mobile - No

Desktop - No

Mobile - No

Desktop - No

Mobile - No

JS and Tags Components

The Profile Tag AddOn uses the Profile Tag library to send asynchronous JavaScript events directly to Intelligent Selling Services Foundation. The profileTag.tag file contains the JavaScript code that calls the Profile Tag script, which then sends the events to Intelligent Selling Services Foundation.

For more information, see Profile Tag.

CMS Components

This AddOn adds the following CMS components:

  • ProfileTagScriptComponent: Creates the CMS Javascript component in the accelerator storefronts.

ImpEx

The new CMS components are imported into the SAP Commerce Cloud Accelerator with the following ImpEx script.
$contentCatalog=electronicsContentCatalog
$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Staged])[default=$contentCatalog:Staged]
$jarResourceCms=jar:com.hybris.yprofile.profiletagaddon.constants.ProfiletagaddonConstants&/profiletagaddon/import/cockpit/cmscockpit
$siteUid=electronics
$lang=en
 
INSERT_UPDATE ConsentTemplate;id[unique=true];name[lang=$lang];description[lang=$lang];version[unique=true];baseSite(uid)[unique=true,default=$siteUid];exposed
;PROFILE;"Allow SAP Commerce Cloud, Context-Driven Services tracking";"We would like to store your browsing behaviour so that our website can dynamically present you with a personalised browsing experience and our customer support agents can provide you with contextual customer support.";1;;true
 
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=append]
;;PlaceholderContentSlot;true;ProfileTagScriptComponent

The profileTagAddonBeforeViewHandler

The profileTagAddonBeforeViewHandler gets executed every time before the view is rendered. The profileTagAddonBeforeViewHandler is responsible for reading the values in the Configuration, and sets these key-values as model attributes.

Installation

For instructions on installing Intelligent Selling Services Foundation integration and Profile Tag AddOn, see Installing Intelligent Selling Services Foundation Integration with B2C Accelerator.

Modifications

The AddOn modifies the Accelerator's ImpEx Configuration Scripts, CMS Components, and JavaScript.

Removing the Consent Reference Cookie

Intelligent Selling Services Foundation is tracking a user's interactions and transactions only if the user has granted their consent for this. Profile Tag allows different consent management settings for each page. When a customer grants their consent for Intelligent Selling Services Foundation, Profile Tag sends a request to Intelligent Selling Services Foundation to receive a new consent reference. In every subsequent request, Profile Tag includes that consent reference, which represents the customer's consent settings.

Removing the consent cookie for the storefront prevents merging of the profiles for different users using the same browser on the same computer. To remove the consent reference cookie, perform the following steps:
  1. Add the RemoveConsentCookieLogoutHandler class directly to your storefront. An example might be de.hybris.platform.yacceleratorstorefront.security.cookie.RemoveConsentCookieLogoutHandler.

    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;
     
     
    public class RemoveConsentCookieLogoutHandler implements LogoutHandler
    {
        private final String consentReferenceCookieNameSuffix;
        private final CookieGenerator cookieGenerator;
        private final BaseSiteService baseSiteService;
     
        public RemoveConsentCookieLogoutHandler(final CookieGenerator cookieGenerator, final String consentReferenceCookieNameSuffix,
                final BaseSiteService baseSiteService)
        {
            this.cookieGenerator = cookieGenerator;
            this.consentReferenceCookieNameSuffix = consentReferenceCookieNameSuffix;
            this.baseSiteService = baseSiteService;
        }
     
        @Override
        public void logout(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication)
        {
            final BaseSiteModel baseSite = baseSiteService.getCurrentBaseSite();
            if (baseSite.getUid() != null)
            {
                final String cookieName = baseSite.getUid() + consentReferenceCookieNameSuffix;
                cookieGenerator.setCookieName(cookieName);
                cookieGenerator.removeCookie(response);
            }
        }
    }
  2. Define 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-config.xml

        <bean id ="removeConsentCookieLogoutHandler" class="com.hybris.yprofile.cookie.RemoveConsentCookieLogoutHandler" >
            <constructor-arg name="consentReferenceCookieNameSuffix" value="-consentReference" />
            <constructor-arg name="cookieGenerator" ref="consentCookieGenerator" />
            <constructor-arg name="baseSiteService" ref="baseSiteService"/>
        </bean>
    
         
         <bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
             <constructor-arg name="logoutSuccessHandler" ref="logoutSuccessHandler" />
             <constructor-arg name="handlers">
                 <list>
                    <ref bean="removeConsentCookieLogoutHandler" />
                    <bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" />
                     <ref bean="rememberMeServices" />
                 </list>
             </constructor-arg>
         </bean>
    ...

For details on consent management for Intelligent Selling Services Foundation, see Consent Management.