활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
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.
해결되었습니다! 솔루션으로 이동.
조회 수
답글
좋아요 수
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
조회 수
답글
좋아요 수
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.
조회 수
답글
좋아요 수
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.
조회 수
답글
좋아요 수
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
조회 수
답글
좋아요 수
조회 수
Likes
답글