Expand my Community achievements bar.

Join us for the next Community Q&A Coffee Break on Tuesday April 23, 2024 with Eric Matisoff, Principal Evangelist, Analytics & Data Science, who will join us to discuss all the big news and announcements from Summit 2024!
SOLVED

Calculate Time between Success Events

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

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

Avatar

Level 2

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

Avatar

Level 2

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

Avatar

Community Advisor

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