JavaScript .push to list

Bronze Contributor
Bronze Contributor

Hello,

how can i add an ID to a list of arrays? 

Right now i am trying to do it with the function b.badge_collection_list.push("1001"). The list of arrays is called "badge_collection_list" in a "Set Data Values" Extension via JS Code. But not even the Extension is loaded on the site.

Would be nice to hear some of your ideas!

Thank you very much

Best regards

Fabian

1 REPLY 1

JavaScript .push to list

Community Manager
Community Manager

@Fabi That is the correct JavaScript syntax to push an element onto an array, so there must be something else that is preventing it from working.

Notice that the value returned from push() is the new length of the array. Are you assigning this value back to the array in the Set Data Value extension?

What is the scope of the extension?

You mentioned:

But not even the Extension is loaded on the site.

Did you publish your changes? Is your site loading the universal tag? If so, which publish environment?

A screenshot of the extension might make it easier to troubleshoot.

Remember to "Accept as Solution" when your question has been answered and to give kudos to helpful replies.
Public