Setting the Data Variable Object with a Data Element | Community
Skip to main content
Level 2
February 3, 2025
Solved

Setting the Data Variable Object with a Data Element

  • February 3, 2025
  • 1 reply
  • 805 views

Hello all,

 

I'm using the Data Object to set eVars to send to Adobe Analytics for reporting purposes. Inside the Data Object, I want to set all the variables using a data element to return a JSON. 

 

My Data object is set to the following.

 

 

var dataTest = { "eVar1": "%dataelement1%", "eVar2": "%dataelement2%", "eVar3": "%dataelement3%" }; return dataTest;

 

 

However, when I check Omnibug to see the values that are being returned, I see this instead of my expected values:

events[0].data.__adobe.analytics.eVar1%dataelement1%
events[0].data.__adobe.analytics.eVar2%dataelement2%
events[0].data.__adobe.analytics.eVar3%dataelement3%

 

Inserting the JSON directly into the same area as the Data Element also returns the correct values instead of the data element names.

 

Did I miss something in my setup, or is it even possible to set these via Data Element and have the values be dynamic?

 

I'm guessing that if a data element is used, it will return the literal string that is in the key value pairs in the JSON. I've also tried using "_satellite.getVar('dataelement1')" as the value and I get "_satellite.getVar('dataelement1')" returned.

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 BryantRe

I worked it out. I needed to remove the quotes around the _satellite.getVar('') command. I was copying the literal format of when you set it manually in the individual parts and needed to adjust. Thanks everyone who took a look at it.

1 reply

BryantReAuthorAccepted solution
Level 2
February 3, 2025

I worked it out. I needed to remove the quotes around the _satellite.getVar('') command. I was copying the literal format of when you set it manually in the individual parts and needed to adjust. Thanks everyone who took a look at it.

bjoern__koth
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
February 4, 2025

Yah you cannot use percentage syntax in a data element with custom code.

Always use _satellite.getVar

Also, should you use the Adobe Client Data Layer, make sure to pass in the event as second parameter

 

_satellite.getVar("some DE", event);

Cheers from Switzerland!