Expand my Community achievements bar.

SOLVED

Old appMeasurement plugins

Avatar

Level 2

Hi All,

we are in the process of implementing Launch, we have quite a few plugins that we used to use in Appmeasurement and would would still like to use, can anyone tell me

1.  Where to place the plugin code?

2.  How do I reference the plugins so they populate the relevant s.props?

Any advice help will be much appreciated.

Best regards.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Under Extensions in Launch, you'll need to install and configure the Adobe Analytics extension (I assume that you've gotten this far).

Within the extension configuration, you'll find a section named "Configure Tracker Using Custom Code".  This is the place where you will add your plug-in functions and set up your s.doPlugins function.

Screen Shot 2018-06-13 at 8.53.08 AM.png

Here is some example implementation code :

Screen Shot 2018-06-13 at 9.05.38 AM.png

In the code above, there are a few things to note:

1) Timing - This code is executed just after the Adobe Analytics library is loaded which is just after the Launch library inits.  In other words, this will run very early in the scheme of things.

2) The first part  (blocked by comments Start ... End) of this code simply defines the plugin functions on the "s" object. This makes them available for use later.

3) line 24 - s.usePlugins=true.  This is a flag for Adobe Analytics that tells it to execute the doPlugins function just before sending beacons across the wire ( as part of s.t, s.tl, activityMap, and link tracking).

4) Lines 25-27 s.doPlugins = ...   This is the function that will be run.  This is where you set you props, evars, events and do anything else you want to accomplish on every beacon that you send.

5) This example shows the structure of things.  You can add more plug-ins and more logic to your doPlugins function.

6) This code would also be a good place for other AA customizations like loading the media module for video tracking.

Links to the documentation are here:

Implementation Plug-ins

s.usePlugins

s.doPlugins

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Under Extensions in Launch, you'll need to install and configure the Adobe Analytics extension (I assume that you've gotten this far).

Within the extension configuration, you'll find a section named "Configure Tracker Using Custom Code".  This is the place where you will add your plug-in functions and set up your s.doPlugins function.

Screen Shot 2018-06-13 at 8.53.08 AM.png

Here is some example implementation code :

Screen Shot 2018-06-13 at 9.05.38 AM.png

In the code above, there are a few things to note:

1) Timing - This code is executed just after the Adobe Analytics library is loaded which is just after the Launch library inits.  In other words, this will run very early in the scheme of things.

2) The first part  (blocked by comments Start ... End) of this code simply defines the plugin functions on the "s" object. This makes them available for use later.

3) line 24 - s.usePlugins=true.  This is a flag for Adobe Analytics that tells it to execute the doPlugins function just before sending beacons across the wire ( as part of s.t, s.tl, activityMap, and link tracking).

4) Lines 25-27 s.doPlugins = ...   This is the function that will be run.  This is where you set you props, evars, events and do anything else you want to accomplish on every beacon that you send.

5) This example shows the structure of things.  You can add more plug-ins and more logic to your doPlugins function.

6) This code would also be a good place for other AA customizations like loading the media module for video tracking.

Links to the documentation are here:

Implementation Plug-ins

s.usePlugins

s.doPlugins

Avatar

Level 2

Hi Stewart,

Thank you for the info.  You are a life saver!!!.

Kind regards

Chris.

Avatar

Level 2

I have done the same steps , but i am getting the warning icon . Could you please help me why i am getting this.

1513789_pastedImage_0.png

Avatar

Community Advisor

It's nothing to worry about. 

I get those too when pasting these plugIns into Launch.  You are safe to ignore them. 

Avatar

Level 9

Be aware some plugins may not work in Launch due to the new compiler/compressor of the scripts. It renames all the variables and "s" isn't always called "s" anymore in the built library.

One I found an already reported via Customer Care is the getVisitNum

Here a fixed verison of that plugin:

/*

* Plugin: getVisitNum - version 3.0

*/

s.getVisitNum=new Function("tp","c","c2",""

+"var s=this,e=new Date,cval,cvisit,ct=e.getTime(),d;if(!tp){tp='m';}"

+"if(tp=='m'||tp=='w'||tp=='d'){eo=s.endof(tp),y=eo.getTime();e.setTi"

+"me(y);}else {d=tp*86400000;e.setTime(ct+d);}if(!c){c='s_vnum';}if(!"

+"c2){c2='s_invisit';}cval=s.c_r(c);if(cval){var i=cval.indexOf('&vn="

+"'),str=cval.substring(i+4,cval.length),k;}cvisit=s.c_r(c2);if(cvisi"

+"t){if(str){e.setTime(ct+1800000);s.c_w(c2,'true',e);return str;}els"

+"e {return 'unknown visit number';}}else {if(str){str++;k=cval.substri"

+"ng(0,i);e.setTime(k);s.c_w(c,k+'&vn='+str,e);e.setTime(ct+1800000);"

+"s.c_w(c2,'true',e);return str;}else {s.c_w(c,e.getTime()+'&vn=1',e)"

+";e.setTime(ct+1800000);s.c_w(c2,'true',e);return 1;}}");

s.dimo=new Function("m","y",""

+"var d=new Date(y,m+1,0);return d.getDate();");

s.endof=new Function("x",""

+"var s=this,t=new Date;t.setHours(0);t.setMinutes(0);t.setSeconds(0);if(x=="

+"'m'){d=s.dimo(t.getMonth(),t.getFullYear())-t.getDate()+1;}else if("

+"x=='w'){d=7-t.getDay();}else {d=1;}t.setDate(t.getDate()+d);return "

+"t;");

The fix is to add "s=this" before "t=new Date" in the "s.endof" function, else the "s.dimo" call in line 19 fails.