On our site we are storing some data in localStorage that we'd love to reference for a Target audience.
We tried to reference it through a profile script, but are presented with an error: "Your updates did not publish to Adobe's delivery network : Invalid script - Syntax or runtime error while executing script"
- The script itself is very basic -- "return window.localStorage.getItem('dnb.industryNaics');"
Our thinking is that this errors because its run on the server and doesn't have access to the individual device's localStorage. Is that correct?
Here's what we can do/plan to do:
1. We can run this all as custom code within an experience and only present the experience if someone fits the value we're looking for. The challenge with this approach is that it takes it out of the VEC so our typical marketer is unable to set it up without developer assistance.
2. We're looking to pass this value from localStorage through the globalMbox for reference in Target audience creation. The issue with this approach is that it won't be available before Target loads the first time, so the audience will only be presented the appropriate experience upon subsequent page loads. Not a big issue, but still not ideal
The other thing we've tried is to delay Target until we have this data available, however that resulted in a very significant 'flicker' for all Target experiences, and was deemed unacceptable by the business.
Does anyone have any other ideas? We certainly have something we can work with, but the perfect solution would:
1. Allow us to create audiences based on the returned values for repeat use by non development users -- allowing VEC use for experience set-up
2. Allow us to provide an experience based on the returned value from the initial page visit, after localStorage is populated on the same page load
3. Not delay Target or impact other experiences with an additional delay -- one thing to note, we would entertain a solution that creates a 'flicker' for only the experience that is referencing localStorage
Thank you for your help!
localStorage is not supported in the AT profile scripts as they are executed server side.
What you may want to do in the profile script is to use: