Hi.
My client's website contains several web apps developed by separate teams. As the apps grow, the teams want to record new data about users, e.g. "unread messages", "new notifications", "qualifies for xyz" and so on.
I'd like to avoid adding new eVars/sProps every time a new piece of metadata comes along.
Does anyone have a clever way of implementing this? Either by:
- a digitalData.user schema that's flexible enough to be reused for most needs
- a way in which we can add key-value pairs to a single eVar/sProp and convert each pair into a new dimension
Any suggestions would be appreciated.
Solved! Go to Solution.
Views
Replies
Total Likes
Code
//Data layer Example
var digitalData = {
"user": {
"attributes": {
"unreadMessages": 2,
"notifications": 5,
"isXyz": true
}
}
}
//Methods to add in custom code of Adobe Analytics extension
var getUserAttributes = function () {
try {
_satellite.logger.log('[Adobe Analytics] Building user attributes details');
return buildStringFromMap(digitalData.user.attributes);
} catch (e) {
_satellite.logger.error('[Adobe Analytics] Failed to build user attributes details -- ' + e);
}
}
var buildStringFromMap = function (map) {
try {
var output = '';
for (var key in map) {
var value = map[key];
if (typeof value == 'boolean') {
value = value ? 1 : 0;
}
if (value instanceof Array && value.length > 0) {
value = value.toString();
}
output += value ? key + '=' + value + '|' : '';
}
return output;
} catch (e) {
_satellite.logger.error('[Adobe Analytics] Failed to build string from map -- ' + e);
}
}
//In Adobe Analytics doPlugins
function s_doPlugins(s) {
s.eVarX = getUserAttributes(); //should return unreadMessages=2|notifications=5|isXyz=1|
}
Now in your report you will see line items as unreadMessages=2|notifications=5|isXyz=1|
Next Steps:
Views
Replies
Total Likes
Code
//Data layer Example
var digitalData = {
"user": {
"attributes": {
"unreadMessages": 2,
"notifications": 5,
"isXyz": true
}
}
}
//Methods to add in custom code of Adobe Analytics extension
var getUserAttributes = function () {
try {
_satellite.logger.log('[Adobe Analytics] Building user attributes details');
return buildStringFromMap(digitalData.user.attributes);
} catch (e) {
_satellite.logger.error('[Adobe Analytics] Failed to build user attributes details -- ' + e);
}
}
var buildStringFromMap = function (map) {
try {
var output = '';
for (var key in map) {
var value = map[key];
if (typeof value == 'boolean') {
value = value ? 1 : 0;
}
if (value instanceof Array && value.length > 0) {
value = value.toString();
}
output += value ? key + '=' + value + '|' : '';
}
return output;
} catch (e) {
_satellite.logger.error('[Adobe Analytics] Failed to build string from map -- ' + e);
}
}
//In Adobe Analytics doPlugins
function s_doPlugins(s) {
s.eVarX = getUserAttributes(); //should return unreadMessages=2|notifications=5|isXyz=1|
}
Now in your report you will see line items as unreadMessages=2|notifications=5|isXyz=1|
Next Steps:
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies