Hi,
I am using AEM 6. How do I added a custom created contextstore to the clientcontext.
Solved! Go to Solution.
Views
Replies
Total Likes
I haven't used that tutorial, but the AEM docs has information on creating stores and interacting with them:
http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/client-context.html#Extending Client Context
http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/client-context.html#Interacting%20with...
Javascript API reference: http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/ccjsapi.html
hope that helps,
Scott
Views
Replies
Total Likes
Views
Replies
Total Likes
I haven't used that tutorial, but the AEM docs has information on creating stores and interacting with them:
http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/client-context.html#Extending Client Context
http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/client-context.html#Interacting%20with...
Javascript API reference: http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/ccjsapi.html
hope that helps,
Scott
Views
Replies
Total Likes
I am following the same tutorial and the issue I am facing is with session store. Here on the line
var authorizableId = CQ_Analytics.ProfileDataMgr.getProperty("authorizableId");
The value of authorizableId is anonymous and I tried the have the output of CQ_Analytics.ProfileDataMgr.getProperty("authorizableId") on console using Console.log. Looks like the CQ_Analytics object is not getting instantiated. I added clientcontext under the body tag. So, I am thinking that maybe I will have to add custom contextstore to the clientcontext. But since this is not defined in the tutoral, I am confused.
Views
Replies
Total Likes
AEM newbie wrote...
The value of authorizableId is anonymous ...
Did you try loading a profile into the client context? Once you load a profile into the client context, and refresh the page, you should get the value of the profile you loaded instead of anonymous.
Views
Replies
Total Likes
Hey thanks for response and I am able to get the value of authorizableId now. But there are still two troublesome issues:
1) The value of CQ_Analytics.CustomStoreMgr.currentId which is not printing at all.
2) The value of CQ_Analytics.CustomStoreMgr.initialized which is false.
Any pointers would be really helpful.
Views
Replies
Total Likes
I am glad to hear you got the value of authorizableId to work. Unfortunately, I have not been able to get their code to work right out of the box. I was able to get currentId, and CQ_Analytics.CustomStoreMgr.initialized to work by using this code in the customstore.js file:
// Create the session store called "customstore" if (!CQ_Analytics.CustomStoreMgr ) { // Create the session store as a JSONStore CQ_Analytics.CustomStoreMgr = CQ_Analytics.JSONStore.registerNewInstance("customstore"); var currentId = ""; // Function to load the data for the current user CQ_Analytics.CustomStoreMgr.loadData = function() { console.info("Loading CustomStoreMgr data"); var authorizableId = CQ_Analytics.ProfileDataMgr.getProperty("authorizableId"); var url = "/apps/customstore/components/loader.json"; url = CQ_Analytics.Utils.addParameter(url, "authorizableId", authorizableId); try { var object = CQ.shared.HTTP.eval(url); if (object) { this.data = object; } } catch(error) { console.log("Error", error); } currentId = authorizableId; }; }
Now if you view the page and run the loadData() function, you should be able to get these two things to work. If you call CQ_Analytics.CustomStoreMgr.initialized it should return a value of true, and if you call "currentId" instead of CQ_Analytics.CustomStoreMgr.currentId, it should return the value of the profile you loaded.
Views
Replies
Total Likes
Hey thanks a lot for that. So just to confirm is this the only piece of code I need to get the code working ? Do I need to include this if check:
if ( (authorizableId !== CQ_Analytics.CustomStoreMgr.currentId) & CQ_Analytics.CustomStoreMgr.initialized ) {
Also, there are some listeners added in Step 7. Do we also need them ?
Thanks again.
Views
Replies
Total Likes