How to capture the current date/time into a eVar

manishs40044499 14-07-2017

Hello All,

I want to capture and save the current date into a eVar which can be used for reporting and analysis purpose later. I can see that date/time into Adobe debugger. Could anybody please help me to capture the same into a eVar.

Also this timestamp is showing in different time zone even though I have selected my current time zone in report suite settings. Please guide me if this can also be changed to proper timezone.

1249071_pastedImage_1.png

Regards,

Manish

Accepted Solutions (1)

Accepted Solutions (1)

ericmatisoff
Employee
05-06-2018

Here's a great start for you: DTM Examples

It will give you all the details on 'setting a global s object' which DTM does not do out of the box. You can then follow my instructions here for creating the doPlugins area:

https://www.searchdiscovery.com/blog/adobe-dtm-update-let-adobe-manage-measurement-library/

You'll want to set up time parting in doPlugins.

Answers (12)

Answers (12)

ursboller
MVP
04-06-2018

ericmatisoff​ minute is not available as dimension in tim-parting. if you look close at the screenshot, the minute is linked to one exact minute, not all the „minutes“ of all hours...

if you want minute as a dimension, you need a custom setup or eait until time-parting will deliver this information.

ericmatisoff
Employee
15-07-2017

Agreed with saurabh kumar​ - time parting plugin is the way to go. I also recommend using Classifications to break it out by:

Day of Week, Month, AM v PM, Weekday vs Weekend.

We've had some customers even break it out by Business Day vs non-Business Day. This can be especially interesting for B2B companies. Enjoy!

Saurabh_Kumar1 14-07-2017

Hello Manish,

   One solution is to use getTimeParting plugin & you can get the time in your desired TimeZone captured in an eVar.

var tpA = s.getTimeParting('n','-7');

s.eVarX = tpA.split('|')[0]; // time at minute level

Reference documentation - getTimeParting

Date / Date range you can always choose for the report whenever you run them in Adobe Analytics.

Regards,

Saurabh Kumar.

marion69081899 18-06-2018

Hello Adobe Community !


Hello ericmatisoff


I don't want to be negative about this, but I tried to follow the tutorial on your document, and it's very well documented,

But even this did not work. I believe there is a problem on the order of loading in the JS objects. The main issue was that the s object was "Unspecified" - and I believe that this was only true when the DTM was calling for this object - since I could use it on the console once every thing was loaded.

But it's ok , I implemented a new context data that manages to give the Date without using the s object as in :

s.getTimeParting = ....

so what id did in my Context data is this :

function addZero(i) {

    if (i < 10) {

        i = "0" + i;

    }

    return i;

}

function myTimePlugin() {

    var d = new Date();

    var h = addZero(d.getHours());

    var m = addZero(d.getMinutes());

    var s = addZero(d.getSeconds());

    var d = addZero(d.getDay());

    switch(d){

        case "01":

            d = "Monday";

            break;

        case "02":

                d = "Tuesday";

                break;

        case "03":

                d = "Wednesday";

                break;

        case "04":

                d = "Thursday";

                break;

case "05":

d = "Friday";

break;

case "06":

d = "Saturday";

break;

case "00":

d = "Sunday";

break;

}

var time2 = h + ":" + m + ":" + s + "|" + d;

return time2;

}

var myTimeStamp = myTimePlugin();

return myTimeStamp;

Sorry for the indentation !

There should be a WYSIWIG for code !

Cheers !

marion69081899 05-06-2018

Hello urs.boller

I can do the custom conf. , but I just wanted to know where would be the best place to do it. On datalement is not working, and either we put the plugin in all of our custom rules, or we do it in the tool custom code (see .PNG) . Before doing this I just wanted to know if Someone had already figured out this :1502034_pastedImage_0.png

ericmatisoff
Employee
04-06-2018

Hi marion69081899​ - good news! There are now pre-built time parting dimensions in Analysis Workspace! So you won't even need to add this plugin. More details here:

Time-Parting Dimensions

marion69081899 04-06-2018

Hello Everyone !

I've been trying to do this, but since the s.code is not accessible in my implementation, we don't know where to put the plugin.

We have tryed in a data element but the s.code is not accessible ( the error is 's not defined') .

Should we put this on the custom code part of the Tool Definition ?


We don't want to go to every rule we have an add this , so if someone knows something please some help would be appreciated !

Cheers !