Expand my Community achievements bar.

How to restrict inclusion of the Target files in head and body.jsp for non-targeted content

Avatar

Level 3

Hi,

We have a requirement where we don't want to make a target calls to be executed when target is disabled for a component. In present scenario, we need to add below code snippet in our page component's head.jsp and body.jsp files to enable targeting.

head.jsp

<sling:include path="contexthub" resourceType="granite/contexthub/components/contexthub" /> <cq:include script="/libs/cq/cloudserviceconfigs/components/servicelibs/servicelibs.jsp"/>

body.jsp

<cq:include path="clientcontext" resourceType="cq/personalization/components/clientcontext"/> <cq:include path="cloudservices" resourceType="cq/cloudserviceconfigs/components/servicecomponents"/>
 

Now, if we create a normal content page using the page template then in that scenario the servicelibs.jsp adds the required javascript objects and references to client-side javascript libraries which we want to restrict for non-targeted content.

How we can achieve such a scenario or if someone has handled the same please share the details.

We are using AEM 6.2.

Thank you,

Regards,

Shikha

1 Reply

Avatar

Level 10

I am searching to see if we have any examples on this use case.