April 26, 2020
Estimated Post Reading Time ~

Issue with turning off location tracker feature(Remove the geolocation store) in 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)




Remove the geolocation store from /etc/clientcontext/new




Change the clientcontext path in Design mode of a page.


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

Unfortunately after implementing the above steps still the geolocation 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");
});


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.