I have this bizarre behaviour when using event.identifier
in a data element.
Background: I have several Direct Calls that actually perform the same action, but set a different s.events
. So instead of creating one rule per Direct Call, I created one single rule and put all my Direct Calls in the rule’s Events
Then I created a data element (storage duration = None) to use a switch-case
to map the Direct Calls’ event.identifier
to the appropriate s.event
switch (event.identifier) {
case 'foo':
return 'event100';
case 'bar':
return 'event200':
// etc
}
Now, this is where the strangeness comes in:
In my rule’s Adobe Analytics action:
- If I use my data element with an eVar, i.e. as
%data element name%
, then my s.event
gets set properly. (I know I’m not supposed to set an s.event
in an eVar
, but this is for troubleshooting.) - BUT if I use my data element in the AA’s custom code, i.e.
s.events = _satellite.getVar('data element name')
, then I get the data element’s default value! This is because event
is apparently undefined inside my data element. that’s what the Adobe debugger’s log shows me: “Failed to execute data element module core/src/lib/dataElements/customCode.js for data element data element name. Cannot read property ‘identifier’ of undefined” - In fact, if I use
_satellite.getVar('data element name')
anywhere, e.g. even with _satellite.logger.log(_satellite.getVar('data element name'))
, I get the undefined error.
I realise that event.identifier
is undocumented, but I learned about it in the Launch community forum, and have got it working for other use cases. So I can’t figure out this particular problem for the life of me.
I also realise that I could move my data element’s switch-case
into the AA custom code itself, but I wanted to separate this logic out in case I need to use the s.event
somewhere else (for whatever reason).
So does anyone know why my data element would work when got with %…%
, but fail when got with _satellite.getVar()
?