- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
I have been going through documentation but still a little uncertain of what the best way of setting an array that persists through a session is. I want an array that starts as empty with the session and as a few events happen a string is added to it in the order that they occur; getting bigger as the session progresses. Any ideas?
If it's just session should be pretty simple
So when new session starts create empty cookie or localstorage variable
When an event happens you add the value to the cookie or localstorage variable using the push() method.
You can use the js extension modules in tealium to create this function,
this is just pseudo talk because it is really hard to be anymore speicfic without something else to go on, if you have any code or scrennshots we can probably direct you better
Thanks for the help! Yes, that is the approach that I was thinking of as well. However, I am having issues setting a value to a cookie variable using JS code.
To be more specific:
I have a variable set up in the Data Layer that is called forms_completed. Based on a condition that is being met, I am trying to add a testing value to it.
I currently have this very simple line in my JS extension:
utag.data["cp.utag_main_forms_completed"] = test;
I am seeing that the extension is being published successfully and the condition is being met but when I search for cp.utag_main_forms_completed in the data layer it does not show up at all. I believe it is not being set to any value. Do you know what I could be doing wrong?
Have you already setup something to create a cookie?
because anything starting with a "cp" in a datalayer is automatically picked up by tealium, it will list all the cookies.
what does your js extension script look like?
Also what are you trying to acheive? what are the testing values you want to test ?
Right now I am just trying to make it show up in the utag.data object. My current JS extension is just setting a value to a cp variable:
utag.data["cp.utag_main_forms_completed"] = "test";
I would like it to be an array and push a form name everytime a new form is completed in my site, but I am not even able to set a simple string to it.
You can not populate a "cp" string in that method, cp is a cookie. you need to update the cookie itself.
Otherwise you can use localstorage, or a combination of audiencestream and IQ .
You literally need to create a function to update cookie values.
Or create a function to update localstorage.
You can't update the cookie value using the method you outlined above.
Copyright All Rights Reserved © 2008-2023