Thursday, April 4, 2019

Issue with turning off location tracker feature(Remove the geolocation store) in Adobe Experience Manager(AEM)

Issue with turning off location tracker feature(Remove the geolocation store) in Adobe Experience Manager(AEM)


I was trying to turn off the location tracker in AEM 6.4, unfortunately it was not working.

Steps Followed:


  • Define new clientcontex- /etc/clientcontext/new (copy the existing /etc/clientcontext/default node through CRXDE)
geo-location-tracker-aem

geo-location-tracker-aem

  • Remove the geolocation store from /etc/clientcontext/new
geo-location-tracker-aem

geo-location-tracker-aem

  • Change the clientcontext path in Design mode of a page.
geo-location-tracker-aem

  • Replicate the design(e.g /etc/designs/default) to publisher


Unfortunately after implementing above steps still the geo location tracker popup was displaying in the browser.

The popup is displayed due to the clientcontext path is still pointing to the default path - /etc/clientcontext/default(Geo Location store is available) instead of pointing to /etc/clientcontext/new(Geo Location store is not available)

 $CQ(function() {
        CQ_Analytics.SegmentMgr.loadSegments("\/etc\/segmentation");
        CQ_Analytics.ClientContextUtils.init("\/etc\/clientcontext\/default", "\/content\/sample\/test");        
    });

Based on the analysis the root cause of the problem is currentStyle.getPath() inside the clientcontext component was returning the wrong path value.

 currentStyle.getPath() was returning /etc/designs/default/jcr:content/homepage but the expected value is /etc/designs/default/jcr:content/homepage/clientcontext(this node has the property path with the value /etc/clientcontext/new) due to the wrong  currentStyle.getPath() is returned server was not able to locate the path property and used the default clientcontext value-/etc/clientcontext/default

 The design path was modified by the below code executed before including the client context - 

if (!getWcmMode().isEdit() && !getWcmMode().isDesign()) {
IncludeOptions.getOptions(getRequest(), true).forceSameContext(true);
getRequest().setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, false);
}

 <div data-sly-resource="${@path='clientcontext', resourceType='cq/personalization/components/clientcontext'}"></div>

The issue is resolved after changing the order of the above code blocks(this order should be maintained even if these two code blocks are in two different files).

<div data-sly-resource="${@path='clientcontext', resourceType='cq/personalization/components/clientcontext'}"></div>

if (!getWcmMode().isEdit() && !getWcmMode().isDesign()) {
IncludeOptions.getOptions(getRequest(), true).forceSameContext(true);
getRequest().setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, false);
}

Now the /etc/clientcontext/new is considered and also the geolocation tracker popup is disabled.

 $CQ(function() {
        CQ_Analytics.SegmentMgr.loadSegments("\/etc\/segmentation");
        CQ_Analytics.ClientContextUtils.init("\/etc\/clientcontext\/new", "\/content\/sample\/test");        
    });


No comments:

Post a Comment