Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

AEM 6.2 - Implementing Server-Side Page Naming for Analytics

Avatar

Level 4

Hi,

We are trying to integrate aem and adobe analytics to show the PageViews and Unique Views details on Sites page analytics and Content Insight.

As we have custom pattern for pageName we tried to implement the server side page names as per the documentation - Implementing Server-Side Page Naming for Analytics .

The issue is getPageName(AnalyticsPageNameContext context) method from custom AnalytciPageNameProvider class is not getting invoked, so because of that we are always seeing incorrect data get stored on the pages.

Note: getResource(AnalyticsPageNameContext context) from custom class is getting invoked. We debugged the AEM 6.2 default analytics bundle and we didn't able to see any occurrence of calling getPageName from custom or default AnalytciPageNameProvider class.

Is this a bug in aem 6.2 or are we missing anything while doing the integration?

Any pointer to fix this will help us more.

Thanks in advance.

-Prem

1 Accepted Solution

Avatar

Correct answer by
Employee

here an example:

@Override
public Resource getResource(AnalyticsPageNameContext context) {
String pageName = context.getPageName();
log.info("Entering getResource for pageName {}", pageName);
ResourceResolver rr = context.getResourceResolver();
if ( ! pageName.startsWith("content")) {
pageName = "content:" + pageName;
}
pageName = "/" + StringUtils.replace(pageName, ":", "/");
log.info("Search for page {}", pageName);
Resource resource = rr.resolve(pageName);
if ( resource.adaptTo(Page.class) != null) {
log.info("Page found");
return resource;
} else {
log.info("Page not found");
}
return null;
}

View solution in original post

4 Replies

Avatar

Administrator

I have asked internally to see if this is known issue.

~kautuk



Kautuk Sahni

Avatar

Level 4

Thanks kautuk for your response!

Please confirm us back, once you got reply from internal team!.

-Prem

Avatar

Employee

The getResource() is called when data is imported from analytics.

getPageName() is called when the direct integration is used.

So this is how it is meant to be.

Avatar

Correct answer by
Employee

here an example:

@Override
public Resource getResource(AnalyticsPageNameContext context) {
String pageName = context.getPageName();
log.info("Entering getResource for pageName {}", pageName);
ResourceResolver rr = context.getResourceResolver();
if ( ! pageName.startsWith("content")) {
pageName = "content:" + pageName;
}
pageName = "/" + StringUtils.replace(pageName, ":", "/");
log.info("Search for page {}", pageName);
Resource resource = rr.resolve(pageName);
if ( resource.adaptTo(Page.class) != null) {
log.info("Page found");
return resource;
} else {
log.info("Page not found");
}
return null;
}