Count the number of visits | Adobe Higher Education
Skip to main content
Level 2
July 3, 2023
Beantwortet

Count the number of visits

  • July 3, 2023
  • 4 Antworten
  • 2283 Ansichten

I'm trying to use this snippet in a profile script to count the the number of visits:

 

if(user.sessionId!=user.getLocal('lastSessionId')) { user.setLocal('lastSessionId', user.sessionId); return (user.get('visitCount') || 0) + 1; }

 

 

For example:
* in the first visits the value expected is "1"

* in the second is "2"
* ...

 

Even if I wait 30m or more for the session to expire and I go back to a page on the site, the value I see is always 1. Can you help me figure out if there is an error?

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von PratheepArunRaj

Dear @jack_hala ,

Did you use the old script and changed only the name to validate? If not, try that as well.

If the visit count didn't increment, then please check the Visitor ID for both sessions. Because the Visitor ID should be the same for both sessions for the profile script to work properly.

Thank You, Pratheep Arun Raj B (Arun) | NextRow DigitalTerryn Winter Analytics

4 Antworten

Perrin_Ennen
Community Advisor
Community Advisor
July 3, 2023

Hi @jack_hala,

Can you try to change your return as follows?

 

if(mbox.name == 'target-global-mbox' && user.sessionId!=user.getLocal('lastSessionId')) { user.setLocal('lastSessionId', user.sessionId); return (profile.get('visitCount') || 0) + 1; // changend line }

 

Hope this helps you.

PratheepArunRaj
Adobe Champion and Community Advisor
Adobe Champion and Community Advisor
July 4, 2023

Dear @jack_hala,

What is the name of the profile script? It should be 'visitCount'.

If it is fine, it should work. Else, please try out the code given by @perrin_ennen with the same name.

Thank You, Pratheep Arun Raj B (Arun) | NextRow DigitalTerryn Winter Analytics

Thank You, Pratheep Arun Raj B (Arun) | Xerago | Terryn Winter Analytics
Level 2
July 5, 2023

Hello, and thank you for your replies.

I changed my scripts and renamed it as follows:

 

But the result is always "1":

 

Do you have any suggestion?

PratheepArunRaj
Adobe Champion and Community Advisor
Adobe Champion and Community Advisor
July 5, 2023

Dear @jack_hala ,

Did you use the old script and changed only the name to validate? If not, try that as well.

If the visit count didn't increment, then please check the Visitor ID for both sessions. Because the Visitor ID should be the same for both sessions for the profile script to work properly.

Thank You, Pratheep Arun Raj B (Arun) | NextRow DigitalTerryn Winter Analytics

Thank You, Pratheep Arun Raj B (Arun) | Xerago | Terryn Winter Analytics