Who here can explain to me what exactly it means to set the “Remember this value for” setting of a Data Element in DTM to anything else but “Page View”?
I can confidently tell you that right now, I have no idea.
Which is of course a perfect excuse to a) find out and b) blog about it.
Rather than just walking up to one of my DTM-savvy colleagues and asking them, I prefer the “let’s hit this thumb with a hammer and see if it hurts approach” as shown in xkcd’s The Difference strip.
So here’s my theory: maybe setting “Remember this value for” to “Session” or “Visitor” means that wherever it gets its value from, it’ll retain that value for the remainder of the session or forever? That the DE will not even check again in that time frame and just play back the latest value? Or maybe that it does check, but if the check returns empty, the DE returns the cached value?
Having theories is great. It means I can now plan experiments to prove those right or wrong! We’re doing science here, people!
What do I need?
- I need a Data Element, of course
- I need to query that DE once, because that’s what will set it. (The way DEs work. The value is calculated when the DE is used.)
- I need to be able to see what the DE did, when I queried it. Did it calculate it’s value or not?
- I need a second query to the DE. This second time will answer my question “does it calculate the value again or not?”
Let’s load the test page:We can see that the DE behaves just like any DE. The switch to “session” makes no difference here, the DE reads the JS object each time it is queried and delivers the current value. Ok.
Let’s reload the page, killing the JS object:A-ha!
We do get a value out of the DE even though the JS object does not support that.
New theory: setting a Data Element to “session” or “visitor” allows the DE to fall back on the last value it determined in situation where getting a value wouldn’t work. How about that?
The obvious question: how?
Well, when you set a DE to anything but “pageview”, DTM stores the last value it got into a cookie named “_sdsat_”, as we can see here:So now I know. And so do you.
Completely separate beast.
Given that I query Data Elements using
getVar(), I would sort of expect to be able to set them using
setVar(), but does that work?
I can, however, set the value of a “custom variable”, that is if I put a name into
setVar() that does not exist as a DE, the system will store the value that I provided and hand it back in a corresponding
getVar() call. Useful if I want to temporarily store information!
setCookie()method. Jim Gordon’s excellent DTM Cheat Sheet has the syntax.