Probably a super simple one this.
Basically, I'm saving the price difference between two products.
In the dataLayer it's a string but it would be handy to save this as a number so I can use it for metrics.
How can I convert the value and save it to an eVar? I've tried the below, but it does absolutely nothing!
var priceDifference = _satellite.getVar("priceDifference");
s.eVar77 = parseFloat(priceDifference);
Solved! Go to Solution.
It is not necessary to convert a number in the string format into a real number if you want to capture it in eVars.
Pay attention, that the eVar syntax above is inaccurate. The correct one is as follows:
if "Adobe Analytics": having the number in an eVar cant be used for calculation. better use a numeric event like "event1=123"
I've set up an event that captures the value of the price difference. Is it better to use numeric or currency when setting up the event type? The values coming in will always be monetary amounts.
if you use a currency event, it will automatically show the currency (of the report suite) in reporting.
on the other hand, you can always create a calculated metric and change to whatever you want to display (currency, numeric,...)
If you only collect and report in one currency (the report suite currency), I would take a currency event. in other cases it's worth to think about using a numeric event.
remark: be aware that by default Adobe Workspace will not display decimals (at least for numeric events). that means if you use a numeric event with decimal numbers, the default metric will just show the full numbers. you can create a calculated metric just containing the original metric and set decimals to whatever you want...
I don't know what default settings for currency metrics is, worth a try...
remark 2: if you only use the calculated metric for reporting think about changing the setting of the metric to be a "builder metric". this will prevent the metric to show up for reporting while it can still be used within segments or calculated metrics. this will reduce the number of times the end user takes the wrong metric
please let me know, I'm interested if decimals show up by default or not.
remark: if you later have another currency, you could still use an additional numeric event (for the other currency) and track in already existing currency event the corresponding value.
simple example (USD Report Suite): if user buy for 10 EUR you report this in a new event ("10") while you write in the old event the corresponding USD amount. this way you can report in USD overall, USD amount from EUR (hit segment where both events are set) and EUR amount (new numeric event als calculated metric)