Calculate Time between Success Events | Community
Skip to main content
Robvienna1982
Level 2
March 14, 2018
Solved

Calculate Time between Success Events

  • March 14, 2018
  • 3 replies
  • 7127 views

I’ve noticed a few threads on this but no definitive answer, some refer to old plugins that no longer work with AppMeasurement...

So, does anyone have a way currently of measuring the time in minutes or seconds between to success events firing. Passing the value into an eVar or Counter Event?

Thanks,

Rob

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by PratheepArunRaj

Dear Rob,

For Web, 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.

For App, 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.

Thank you!

Arun

3 replies

PratheepArunRaj
Community Advisor and Adobe Champion
PratheepArunRajCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
March 15, 2018

Dear Rob,

For Web, 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.

For App, 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.

Thank you!

Arun

Thank You, Pratheep Arun Raj B (Arun) | Xerago | Terryn Winter Analytics
Level 2
October 4, 2022

Hi Arun,

The links for apps are going to the community homepage. Are you aware if these functions are still available? Were should I search for them?

 

Thank you

Dim

Robvienna1982
Level 2
March 15, 2018

Hi Arun,

Thanks for this, does the plugin work with AppMeasurement though? Have you got an example report that this might produce so I can understand how it is visually?

Thanks,

Rob

PratheepArunRaj
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
March 16, 2018

Dear Rob,

We have implemented this in Legacy Version and thus i am not sure on the App Measurement.

Based on the link AppMeasurement Plug-in Support from Adobe, it was said that the Plugin was compatible.

Cannot show the report, but the variable will be captured in the buckets like 1 minute, 1.5 minutes, 2 minutes etc.

If the above didn't work, then use data elements in DTM to capture the time frame between events and calculate it to pass into a variable. Javascript developer should know this.

Thank You

Arun

Thank You, Pratheep Arun Raj B (Arun) | Xerago | Terryn Winter Analytics