내 커뮤니티 업적 표시줄을 확대합니다.

Adobe Experience Platform (AEP) & Apps User Groups are live to Network, learn, and share in your regional locations.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

saving an object or array in a data element in Adobe Dynamic Tag Manager

Avatar

Level 1

I tried to save a javascript array or javascript object in a data element in DTM, but it does not work. It just translates it to an encoded string.

Is there a way to make this work?

If not, how am I supposed to populate data of a dynamic size, for example an array of each item in the cart, with individual attributes (name, price, quantity), for each one?

I have a PIWIK script that is expecting this on the confirmation page.

I can collect and save this data to a js object on my page, but I am not able to successfully use this data in DTM.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Employee


Ok, I thought you were creating the object in the Data Element.

If you have an array like var items = ['foo', 'bar', {key: 'value'}] either in a data element or in the DOM (in the page), or in a custom script section in DTM, you could reference elements of the array in a few ways:   

items[2].key // returns 'value' from the above array _satellite.data.customVars.object_test[2].key  // returns 'value' from a data element called object_test that contains the array _satellite.data.customVars.object_test[0]  // returns 'foo' %window._satellite.data.customVars.object_test[2].key%  // returns 'value' from the data element, in the user interface fields

원본 게시물의 솔루션 보기

3 답변 개

Avatar

Employee

Are you returning the object as the last line of the script for the data element?

var myObject = { key = "value", foo = "bar" }; return myObject;

With custom script data elements or conditions, the return statement is required.

Avatar

Level 1

that does not work.

i tried this as my data element custom script:

return window.piwikVars.items;

 

then in my script tag i am adding:

var myArray = %piwikItems%;

 

but it is not seeing as an array: it is giving an error like this:

[img]Screenshot 2014-10-09 16.42.45.png[/img]

 

i can see the populated array in my DOM inspector so I know that the variable exists and is populated correctly.

Avatar

정확한 답변 작성자:
Employee


Ok, I thought you were creating the object in the Data Element.

If you have an array like var items = ['foo', 'bar', {key: 'value'}] either in a data element or in the DOM (in the page), or in a custom script section in DTM, you could reference elements of the array in a few ways:   

items[2].key // returns 'value' from the above array _satellite.data.customVars.object_test[2].key  // returns 'value' from a data element called object_test that contains the array _satellite.data.customVars.object_test[0]  // returns 'foo' %window._satellite.data.customVars.object_test[2].key%  // returns 'value' from the data element, in the user interface fields