Hi,
I'm trying the code below in a profile script but it is never incremented.
if(user.sessionId!=user.getLocal('lastSessionId')) {
user.setLocal('lastSessionId', user.sessionId);
return (user.get('visitCount') || 0) + 1;
}
For test it faster, i override the sessionIdLifetime at 30 sec.
The sessionId change works fine.
But visitCount is always blocked at 1.
Do you know why ?
Views
Replies
Total Likes
It seems the value of user.getLocal('lastSessionId') always start in the IF condition with "null"
in the mboxTrace this variable is identified with user.123456789.lastSessionId
I don't know how to get the right lastSessionId stored in the IFcondition?
did you set 'visitCount' first before getting the value?? because first time it will start with 0 but before return you have to set it to user or somewhere in local storage so that next time 'visitCount' will return saved value rather going to 0 you can read for user.
also refer - https://experienceleague.adobe.com/docs/target/using/audiences/visitor-profiles/variables-profiles-p...
Hi, i tried to store the value in local storage and it's work fine when user is in the same session.
But when a new session starts, the storage is deleted and comes back to 0...
Have you got an idea ?
why don't you try the combination of these three to achieve your requirement (something as below, just coded roughly)
if(user.isFirstSession){
user.setLocal("lastsession",user.sessionId);
return (user.get('visitCount') || 0) + 1;
}else if(user.isNewSession){
if(user.getLocal("lastsession")!=user.sessionId){
user.setLocal("lastsession",user.sessionId);
return (user.get('visitCount') || 0) + 1;
}
}
I think i don't really know how to check the setting...
For me the user.get('visitCount') is set by the "return" statement and is reachable from the second time.
If i put just this line in the profile script, the incrementation will work :
return (user.get('visitCount') || 0) + 1;
But once i add session instruction the incrementation is down..
Views
Likes
Replies
Views
Likes
Replies