Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

User metadata "template" for digitalData

Avatar

Avatar
Validate 1
Level 1
danielwalo
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
danielwalo
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
danielwalo
Level 1

07-07-2020

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. 🙂 Cheers.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
AlexisCazes
MVP

Likes

185 likes

Total Posts

420 posts

Correct Reply

198 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
MVP
AlexisCazes
MVP

Likes

185 likes

Total Posts

420 posts

Correct Reply

198 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
AlexisCazes
MVP

07-07-2020

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:

Answers (0)