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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Text Values for Events

Avatar

Level 1

Hello,

If I register an event 

event1=fizzbuzz

on a click, and later on a different click,

event1=buzzfizz

will I get metrics for each value passed in the event? Is that how the text string option works?

 

Thanks.

 

mp

7 Replies

Avatar

Level 4

Hi,

 

I am going to assume you are asking about event id serialization? (https://experienceleague.adobe.com/docs/analytics/implementation/vars/page-vars/events/event-seriali...)

 

Events are counters, they aren't "text", but you can append text, not with an equals (=) sign, but with a colon (:).

 

  • event1=x (this is used for events set up as "numerical" or "currency" to pass a custom numerical value to count by - example, let's say I wanted to track the number of search results returned on a page, and 8 results were returned, I could track event1=8 and for that one page view, my custom counter would show 8, or whatever number I actually passed)
  • event1:fizzbuzz (this creates an "event id", no matter how many times I send "event1:fizzbuzz" only the first one will count. That is because Event Serialization is set up with the Unique Event Recording settings: 
    JDungan_0-1651600310362.png


    To "always" record the event, to record once per visit, or once per unique id passed. This is handy for tracking things like user registrations where you are afraid the user may refresh the page, or go backwards and trigger multiple times, or for things like purchases/subscriptions/etc that have a unique reference code)

 

If you are trying to get events counted per "value" (i.e. buzzfizz got 140, and fizzbuzz got 97) then there are a few ways to go...

 

IF on the trigger you will only every have one value, you can just use a prop or evar to hold the value. Then in your reports you can use your event1 metric and breakdown by your prop or evar to get the counts per value.

 

IF your trigger is passing multiple values, but the counts are always 1 per... then you can use a prop (set up as a list variable) or use one of your three list variables to pass each of the values you want counted, and just like above, use your event1 metric and break down by your dimension to get your individual counts.

 

IF your trigger is passing multiple values and the counts are different per value, this gets complicated (not impossible, I do this frequently) to make sure that the count but it does require using your one and only s.product (yes this is technically supposed to be use for shopping cart purchases, but it's the ability to explicitly connect a metric (with a specific counter) to a value (without impacting the other value)...

For instance (and sorry for the code if you aren't familiar)

[optionalCat];buzzfizz;;;event1=2,[optionalCat];fizzbuzz;;;event1=1

in this case, buzzfizz will be given a count of 2 while fizzbuzz will only get a count of 1 (separate counts for separate values). In this case, the event1 must be configured to be numerical (not a counter), so that it will take the = notation to pass a specific value

Avatar

Level 4

I should have also noted that you could also pass the value buzzfizz and fizzbuzz into merchandising eVars as well in the above notation (this is actually a good idea, as it's easier to create filters and segments on the merchandising eVar than on the Product).

Avatar

Level 1

Hello,

 

Thank you for the prompt and detailed reply. I'm tasked with tracking a large number of disparate user interactions that all occur within the umbrella of a specific company program, all of which occur in modals or page assets, not on pages themselves. I'm also tasked with using as few variables as possible. 😉 I want to be able to create reports that group together events that occur within the same modal. e.g., one modal has 7 possible event values (always one at a time), another has 4, and so on. Most of these events occur on a click event. Taking your suggestion to put the value in the eVar and using the event as a counter, it seems I could create these reports by segmenting with the name of the modal, which is captured in a prop. Does that seem workable?

 

Thanks.

 

mp 

Avatar

Level 4

That sounds like you have it.. and since these are on click events, you could also use the custom link value to help give context.

 

So for instance, you could reference the model/asset as "[asset x] interaction" or "cta: [asset x] interaction", etc (following your standard naming convention), then set the prop with the event value (this would be your unique text to tell the actions apart), and use one event to track all "asset interactions".

 

In your report you would then use your prop as the dimension and the event as the counter. If you need to segment to a specific page asset, you could create a segment looking at the custom link value (rather than having to use a list of "these 5 values").  If multiple assets have the same action (like "click" or "expand" or "collapse", or whatever those actions would be) you could use the same generic names because you know what asset it's on from the custom link value, rather than having to set specific actions per asset like "asset x click" or "asset y click". This would allow you to roll up all clicks, or all expands, etc. 

 

I use this model all the time, it allows me to combine or segment out data easier depending on who is asking for a report and what they need to be able to see.

Avatar

Community Advisor

Right so I have an implementation on my side where we need to collect the application attribute details which sometimes can be over 20 at a time. I have the same restriction as you where I should only use minimum amount of variables, in my case one.

 

The best solution is to use an eVar as you can set up to 250char, we will put a concatenated value of key=value pairs delimited by a pipe "|". Each key will be an ID instead of the full name to limit the char usage. I then use Classification rule builder using Regex to split each key/pair values into their own reports. I can also create calculated metrics based on the values to get the individual metrics.

 

Also as it seems you have modals then you would use s.tl instead of s.t call so we will provide a custom name for each interaction in s.tl which result in new line item in the custom link report.

 

So lets say per your example we want to track type of component (i.e modal or page asset), type of interaction, etc..

 

s.eVarX = "loc=modal|ev=CLICK|item=BUTTON|value=myvalue123"

 

What we want is to create dynamic values so if a key does not have a value we do not want to put, use this code to achieve this:

 

Data Element code: 

/**
 * The mapping value can either be a function, hard co
 */
function builKeyValue(key, config) {
    try {
        var value = '';

        if (!config[key]) {
            return '';
        }
        //get value
        if (typeof config[key] == 'function') {
            value = config[key]();
        } else {
            value = _satellite.getVar(config[key]);
        }

        //transform value    
        if (typeof value == 'boolean') {
            value = value ? 1 : 0;
        }

        if (value instanceof Array && value.length > 0) {
            value = value.toString();
        }
        return value ? key + '=' + value + '|' : '';
    } catch (e) {
        _satellite.logger.error('[Build string from map] Failed to build key/value for key ', key);
        return '';
    }
}

function buildStringFromMap(config) {
    try {
        var output = '';

        for (var key in config) {
            output += builKeyValue(key, config)
        }

        return output;
    } catch (e) {
        _satellite.logger.error('Failed to build string from map -- ', e);
    }
}

var mapping = {
    "loc": "componentDataElement",
    "ev": "eventDataElement",
    "item": "itemDataElement",
    "value": "valueDataElement"
}

return buildStringFromMap(mapping);

For the rule builder create the classification in advance and then in the classification rule builder create a rule based on regex:

Rule type: Regular expression

Match criteria: ^.*loc=([^\|]+)\|.*$

Classification: Select the target classification report name

To: $1

 

Hope this helps

 

Avatar

Level 4

Yes! Rocking the concatenated values and classification rules is a great solution if you need to track multiple values while minimizing the number of parameters (just make sure you don't exceed 250 characters).

 

If you are afraid of that, if you build in an "end identifier" (yes this will take a few more characters away), then you can watch for this value, and where missing create an alert or some rules to indicate that some data is lost.

Avatar

Community Advisor

Also as we are using classification you can use numeric values for some key=pair. like for loc we know we will have modal, you can replace each possible values by a number so modal would be 1 loc=1 etc... During classification you can translate to correct string values in the classified reports