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

Customizing client context

Avatar

Level 4

Hi,

I am using AEM 6.0 and trying to customize client context. I am following the URL http://blogs.adobe.com/aemtutorials/2013/07/24/customize-the-client-context/ and have checked out the latest code from codehub and deployed in the local AEM. I opened up the page /content/geometrixx-outdoors/en/men/coats/edmonton-winter.html on Chrome and checked the response on Console. I used console.log statements in the customstore.js to see the output in the Console. The if statement in the checked out code the(inside customstore.js) is not getting called at all. The value of authorizableId being fetched from 

var authorizableId = CQ_Analytics.ProfileDataMgr.getProperty("authorizableId");

is anonymous as seen in the Console.log statement. I am not able to see the output in the Console as shown on  http://blogs.adobe.com/aemtutorials/2013/07/24/customize-the-client-context/

Is there anything extra that I need to do ?

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You have included the client context correctly. Once you include that line of code, you can use the client context to view data. 

Are you following along with the tutorial, or did you install the full code at the very end? I tried doing this tutorial, and if you install the completed code, and try doing step 4, it will only return "Object {}", but if you replace the code inside "customstore.js" with the code from step 2, it will display the correct results in step 4. You need to make sure you have a profile loaded in the client context that is not anonymous for it to display the object data.

Also, when you tried printing "CQ_Analytics.CustomStoreMgr.currentId", the reason that did not work is because that is not a valid option. When you are in the console you can use the intellisense to see a list of methods and variables you can access for your session store.

View solution in original post

8 Replies

Avatar

Level 10

Hi,

Is CQ_Analytics object is present in the console ?? If not, then you might have missed including the clientContext in your JSP. 

Avatar

Level 4

Hi,

I have included the client context in the body.jsp of the basepage. Is there anything else I need to do to make CQ_Analytics object available ? I also tried to print the value of CQ_Analytics.CustomStoreMgr.currentId in console log but it is printing as it is rather than printing the value.

Avatar

Level 8

AEM newbie wrote...

Hi,

I have included the client context in the body.jsp of the basepage. Is there anything else I need to do to make CQ_Analytics object available ?

 

From http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/client-context.html#Adding Client%20Context%20To%20A%20Page:

To include the component, add the following code to the JSP file of your page component, located just below the body element of your page:

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

Scott

 

Avatar

Level 4

Thanks for the response. This is how I have included the clientcontext. Do you mean I have to include it some other way ?

<body> <cq:include path="clientcontext" resourceType="cq/personalization/components/clientcontext"/> <div class="wrapper"> <div class="pre-login__container"> <cq:include script="header.jsp"/> <cq:include script="main.jsp"/> </div> </div> <cq:include script="footer.jsp"/> <cq:include path="timing" resourceType="foundation/components/timing"/> <cq:include path="cloudservices" resourceType="cq/cloudserviceconfigs/components/servicecomponents"/> </body>

Avatar

Correct answer by
Former Community Member

You have included the client context correctly. Once you include that line of code, you can use the client context to view data. 

Are you following along with the tutorial, or did you install the full code at the very end? I tried doing this tutorial, and if you install the completed code, and try doing step 4, it will only return "Object {}", but if you replace the code inside "customstore.js" with the code from step 2, it will display the correct results in step 4. You need to make sure you have a profile loaded in the client context that is not anonymous for it to display the object data.

Also, when you tried printing "CQ_Analytics.CustomStoreMgr.currentId", the reason that did not work is because that is not a valid option. When you are in the console you can use the intellisense to see a list of methods and variables you can access for your session store.

Avatar

Level 4

Hey thanks again for your response. Really appreciate it. I pulled the code from git and installed it, I have loaded the profile and finally able to see the value of authorizableId. But I am not sure how to go about CQ_Analytics.CustomStoreMgr.currentId and CQ_Analytics.CustomStoreMgr.initialized. What I exactly mean is what do I need to make these work or use something else.

Avatar

Former Community Member

I replied to your other post. I hope that it helps you.

Avatar

Level 2

Is there a way to get client context data in AEM component (instead of segments)...appreciate any help in this regard

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----