Average time between 2 suces events

marion33678522 16-02-2018

Hello Adobe Community,

I've been asked to mesure the average time between 2 different events on unique visitors ( so first event can happen in visit number x, and second event on another separeted visit ).

How can this be done ? There was a document on a Time To Complete Plug-in , but without any explanation.

Kind regards,


Cheers,

Mario

Accepted Solutions (1)

Accepted Solutions (1)

ursboller
MVP
22-02-2018

marion33678522​ btw: if you are using the adobe moblie sdk‘s, there is a function specially for this:

iOS: Timed Actions

Android: Timed Actions

you could just hand over the desired events and links above to the devs, should be straight forward ...

Answers (7)

Answers (7)

ursboller
MVP
19-02-2018

hi mario

the solution written by PratheepArunRaj​ is really short, would try to go with that.

btw: i don‘t think this will work with a mobile sdk. but you can ask the developpers to do same:

1) save timestamp on first action

2) save timestamp on second action

3) calculate difference 2)-1) and send data to analytics

4) save data to prop/evar in analytics backend

PratheepArunRaj
Moderator
16-02-2018

Dear Mario,

Include the plugin and add the below codes in s_doPlugins section.

>>Code Start<<

if (s.events && (s.events + ",").indexOf("event1,") > -1) {

s.prop1 = "start"

}

if (s.events && (s.events + ",").indexOf("event2,") > -1) {

s.prop1 = "stop"

}

s.prop1 = s.getTimeToComplete(s.prop1, "TTC", 0);

>>Code End<<

Plugin:

>>Code Start<<

s.getTimeToComplete = new Function("v", "cn", "e", "var s=this,d=new Date,x=d,k;if(!s.ttcr){e=e?e:0;if(v=='start'||v=='stop')s.ttcr=1;x.setTime(x.getTime()+e*86400000);if(v=='start'){s.c_w(cn,d.getTime(),e?x:0);return '';}if(v=='stop'){k=s.c_r(cn);if(!s.c_w(cn,'',d)||!k)return '';v=(d.getTime()-k)/1000;var td=86400,th=3600,tm=60,r=5,u,un;if(v>td){u=td;un='days';}else if(v>th){u=th;un='hours';}else if(v>tm){r=2;u=tm;un='minutes';}else{r=.2;u=1;un='seconds';}v=v*r/u;return (Math.round(v)/r)+' '+un;}}return '';");

>>Code End<<

If the implementation requires any other plugin support, include them as well.

Note that the value will be visible only in the 2nd image request i.e. After 2nd event occurs.

Thank You

Arun

ursboller
MVP
22-02-2018

marion33678522

don‘t know, but there could be a way to store the first timedstamp within the app for a longer time (so it is available at the second event)

just to make sure: doing this, you will only get ONE analytics call with a time information. therefore it does not depend on “visits in analytics“ but on the framework collecting the information (eg. app).

marion33678522 19-02-2018

Thanks alot PratheepArunRaj​ ;


I'll try this,

But do you know if this also works for 2 different sessions on an app (Before I go to my sdk teams and implement a new app build ).

Kind regards,


And cheers,


Mario


Mar