s.getPreviousValue not working for other eVars than page name and channel | Community
Skip to main content
chrisludwig87
Level 2
September 23, 2024
Solved

s.getPreviousValue not working for other eVars than page name and channel

  • September 23, 2024
  • 2 replies
  • 1302 views

Hi there,

I do initialize the getPreviousValue-Plugin with Data Collection and then setting two eVars by using an additional rule, the Adobe Analytics extension and custom code looking like this:

s.eVar18 = s.getPreviousValue(s.pageName,"gpv_pageName"); s.eVar19 = s.getPreviousValue(s.channel,"gpv_siteSection");

Everything is working fine for this. Cookies are set, eVars are set as soon as cookies have a value.

Now, I'm trying to add an additional line, looking like this:

s.eVar17 = s.getPreviousValue(s.eVar2,"gpv_pageId");

For this one, no cookie is built and therefore no eVar is set while eVar2 exists in the tracking calls.

Can someone tell me why?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by bjoern__koth

Hi @chrisludwig87 

are you sure that eVar2 has been set by the time you are calling getPreviousValue?

What if you log it in the console? Do you see an actual value present?

_satellite.logger.debug(">>> this is eVar2", s.eVar2);

2 replies

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
September 23, 2024

Hmm on the surface, this looks fine... 

 

The only thing I can think of is your eVar2 being explicitly set? Or is it maintaining a value from a previous page (I assume not since it's called "page id", so I would expect that to be set for every page)

 

There should be no difference between maintaining the value of pageName or channel, or an eVar.... I even see eVars in the examples in the documentation.

 

Are you seeing any errors in your console?

 

I don't use this plugin, so to try and replicate I need to do some setup.... 

chrisludwig87
Level 2
September 23, 2024

Thanks for your thoughts. I don't get any console errors. You're right, s.eVar2 is set on every page tracking call. It feels weird that both others are working as expected, seeing no difference to s.eVar2.

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
September 23, 2024

It really does.... just for a test.. can you try something else? just to see if the cookie gets properly set? Maybe try a prop and another eVar (something that should always be there)... 

bjoern__koth
Community Advisor and Adobe Champion
bjoern__kothCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
September 23, 2024

Hi @chrisludwig87 

are you sure that eVar2 has been set by the time you are calling getPreviousValue?

What if you log it in the console? Do you see an actual value present?

_satellite.logger.debug(">>> this is eVar2", s.eVar2);
Cheers from Switzerland!
chrisludwig87
Level 2
September 24, 2024

That's it. I just changed the load order so that the rule explicitly for the GPV-values is a step after the "basic variable" set and now it's working. This means eVar2 wasn't set when the GPV jumped in—timing issue.

bjoern__koth
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
September 24, 2024

Great you figured it out!

Cheers from Switzerland!