setting s.evar in custom code does not work | Community
Skip to main content
Level 2
April 22, 2024
Solved

setting s.evar in custom code does not work

  • April 22, 2024
  • 1 reply
  • 1833 views

I am trying to set an eVar using custom code in Launch through the Analytics Extension. So far, nothing is working, no matter how I try to set it. I see the data that I want in the console, so I know I am receiving it correctly. Is there something I need to do differently or include? I see the test string for the link track as well...

 

console.log("%c ******", "color: red; font-size: 20px"); _satellite.logger.log(event.element.getAttribute('data-acid')); let evarValue = event.element.getAttribute('data-acid') || "No Data Written"; _satellite.logger.log(evarValue); // s.linkTrackVars = "eVar87"; s.eVar87=evarValue; s.tl(this,'o','Link Track in JS v2 Test')

 

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 Jennifer_Dungan

Hi @justcallmepcra12,

 

I set eVars in Custom Code all the time, so I know it works.

 

However, I can see that you are sending a custom link, so you will need the s.linkTrackVar to be set (it's currently commented out), but if there are other dimensions / metrics also being set by the Adobe Extension, all of them will have to be set in the declaration as well.

 

For instance, if you are using the Set Variables to set eVar1 and prop1, instead of just:

s.linkTrackVars = "eVar87";

 

You will need to have:

s.linkTrackVars = "prop1,eVar1,eVar87";

(order doesn't matter)

 

To ensure that the Custom Link sends all the dimensions on the tracking call.

 

 

Where is this code being added in Launch? It is inside action of a Rule right? I am checking in case this isn't somewhere (like a Data Element) being executed before the s object is ready on the page, which could be causing the last two lines to fail. 

1 reply

Jennifer_Dungan
Community Advisor and Adobe Champion
Jennifer_DunganCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
April 22, 2024

Hi @justcallmepcra12,

 

I set eVars in Custom Code all the time, so I know it works.

 

However, I can see that you are sending a custom link, so you will need the s.linkTrackVar to be set (it's currently commented out), but if there are other dimensions / metrics also being set by the Adobe Extension, all of them will have to be set in the declaration as well.

 

For instance, if you are using the Set Variables to set eVar1 and prop1, instead of just:

s.linkTrackVars = "eVar87";

 

You will need to have:

s.linkTrackVars = "prop1,eVar1,eVar87";

(order doesn't matter)

 

To ensure that the Custom Link sends all the dimensions on the tracking call.

 

 

Where is this code being added in Launch? It is inside action of a Rule right? I am checking in case this isn't somewhere (like a Data Element) being executed before the s object is ready on the page, which could be causing the last two lines to fail. 

Level 2
April 22, 2024

Wow thank you for your suggestion. I will make those changes and give update. Yes I am setting this inside a rule in the Analytics Set Variables

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 22, 2024

Ok, perfect. This is where I set my custom code as well.

 

One of my "tricks" is that I have a long list of correlation variables that I use on all clicks / actions, then some actions have their own unique dimensions... so in my Adobe Analytics extension, I set my base dimensions into a window scoped variable:

 

window.correlationVariables = "prop1,prop2,eVar1,eVar2,eVar3";

 

Then in my custom code I use:

s.linkTrackVars = window.correlationVariables + ",eVar87";

 

So that I don't have to write out the full list of items each time, and just focus on adding my specific dimensions for each use.... If I then add a new dimension that needs to be added everywhere, I only have to edit the one line of code where I set the initial list.