Expand my Community achievements bar.

Join us at Adobe Summit 2024 for the Coffee Break Q&A Live series, a unique opportunity to network with and learn from expert users, the Adobe product team, and Adobe partners in a small group, 30 minute AMA conversations.
SOLVED

Tracking new or repeat visitors using doplugin in appmeasurement for JS

Avatar

Level 3

Team,

We are planning to track the "new or repeat" visitors through doPlugins function. We have made all the initial configuration and the necessary settings to track those visitors from the plug in. However, Still we don't see the right data on the respective variable (Conversion variable). We feel like that we are missing or making some information incorrectly. We are using Tealium IQ as our tag management system and have added the plug in code under the java script extension. Also, using "Adobe Analytics App Measurement for JS" as a tag.

Please check the below and assist me to get the "new or repeat" visitors as expected.

----------------------------------Actual Code on my JavaScript extension---------------------

// Type your JavaScript code here...

//initialize AppMeasurement

var s_account="RSID"; //my RSID comes here

var s=s_gi(s_account);

/******** VISITOR ID SERVICE CONFIG - REQUIRES VisitorAPI.js ********/

s.visitor=Visitor.getInstance("INSERT-MCORG-ID-HERE");

/************************** CONFIG SECTION **************************/

/* You may add or alter any code config here. */

/* Link Tracking Config */

s.trackDownloadLinks=true;

s.trackExternalLinks=true;

s.trackInlineStats=true;

s.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx";

s.linkInternalFilters="javascript,fasenra.com"; //optional: add your internal domain here

s.linkLeaveQueryString=false;

s.linkTrackVars="None";

s.linkTrackEvents="None";

/* uncomment below to use doPlugins */

s.usePlugins=true;

s.doPlugins=function(s) { 

   

// GET NEW or REPEAT Visitors

s.eVar13 = s.getNewRepeat(30,'s_getNewRepeat');

/*

* Plugin: getNewRepeat 1.2 - Returns whether user is new or repeat

*/

s.getNewRepeat=new Function("d","cn",""

+"var s=this,e=new Date(),cval,sval,ct=e.getTime();d=d?d:30;cn=cn?cn:"

+"'s_nr';e.setTime(ct+d*24*60*60*1000);cval=s.c_r(cn);if(cval.length="

+"=0){s.c_w(cn,ct+'-New',e);return'New';}sval=s.split(cval,'-');if(ct"

+"-sval[0]<30*60*1000&&sval[1]=='New'){s.c_w(cn,ct+'-New',e);return'N"

+"ew';}else{s.c_w(cn,ct+'-Repeat',e);return'Repeat';}");

/*

* Utility Function: split v1.5 (JS 1.0 compatible)

*/

s.split=new Function("l","d",""

+"var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x"

+"++]=l.substring(0,i);l=l.substring(i+d.length);}return a");


}

// s.doPlugins=s_doPlugins;

s.trackingServer="sstats.adobe.com";

s.trackingServerSecure="fasenracom.sc.omtrdc.net";

-------------------------------------------------------------------------------------------------------------------------------------------

Thank you,

Jay.

1 Accepted Solution

Avatar

Correct answer by
Employee

Put the plugin code out side and above the doPlugins function then call the s.getNewRepeat inside the doplugin code.

That should solve the issue. Refer the order of the code below :

/*

* Plugin: getNewRepeat 1.2 - Returns whether user is new or repeat

*/

s.getNewRepeat=new Function("d","cn",""

+"var s=this,e=new Date(),cval,sval,ct=e.getTime();d=d?d:30;cn=cn?cn:"

+"'s_nr';e.setTime(ct+d*24*60*60*1000);cval=s.c_r(cn);if(cval.length="

+"=0){s.c_w(cn,ct+'-New',e);return'New';}sval=s.split(cval,'-');if(ct"

+"-sval[0]<30*60*1000&&sval[1]=='New'){s.c_w(cn,ct+'-New',e);return'N"

+"ew';}else{s.c_w(cn,ct+'-Repeat',e);return'Repeat';}");

/*

* Utility Function: split v1.5 (JS 1.0 compatible)

*/

s.split=new Function("l","d",""

+"var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x"

+"++]=l.substring(0,i);l=l.substring(i+d.length);}return a");

s.doPlugins=function(s) {

/ GET NEW or REPEAT Visitors

s.eVar13 = s.getNewRepeat(30,'s_getNewRepeat');

};

// s.doPlugins=s_doPlugins;

View solution in original post

8 Replies

Avatar

Correct answer by
Employee

Put the plugin code out side and above the doPlugins function then call the s.getNewRepeat inside the doplugin code.

That should solve the issue. Refer the order of the code below :

/*

* Plugin: getNewRepeat 1.2 - Returns whether user is new or repeat

*/

s.getNewRepeat=new Function("d","cn",""

+"var s=this,e=new Date(),cval,sval,ct=e.getTime();d=d?d:30;cn=cn?cn:"

+"'s_nr';e.setTime(ct+d*24*60*60*1000);cval=s.c_r(cn);if(cval.length="

+"=0){s.c_w(cn,ct+'-New',e);return'New';}sval=s.split(cval,'-');if(ct"

+"-sval[0]<30*60*1000&&sval[1]=='New'){s.c_w(cn,ct+'-New',e);return'N"

+"ew';}else{s.c_w(cn,ct+'-Repeat',e);return'Repeat';}");

/*

* Utility Function: split v1.5 (JS 1.0 compatible)

*/

s.split=new Function("l","d",""

+"var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x"

+"++]=l.substring(0,i);l=l.substring(i+d.length);}return a");

s.doPlugins=function(s) {

/ GET NEW or REPEAT Visitors

s.eVar13 = s.getNewRepeat(30,'s_getNewRepeat');

};

// s.doPlugins=s_doPlugins;

Avatar

Level 3

Hi Hariskum,

Thanks for your reply. I have modified the code as suggested and still I don't see the tags firing. Also, this was implemented in Tealium IQ JavaScript extension. I have also mapped the "eVar13" to the respective data layer. Please check and let me know if any. Tried with implementing in other scenario as well but it is also not firing.

//initialize AppMeasurement

var s_account="ageo1xxlonsamplepeeranalytics";

var s=s_gi(s_account);

/******** VISITOR ID SERVICE CONFIG - REQUIRES VisitorAPI.js ********/

s.visitor=Visitor.getInstance("INSERT-MCORG-ID-HERE");

/************************** CONFIG SECTION **************************/

/* You may add or alter any code config here. */

/* Link Tracking Config */

s.trackDownloadLinks=true;

s.trackExternalLinks=true;

s.trackInlineStats=true;

s.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx";

s.linkInternalFilters="javascript:,tealiumecommerce.com"; //optional: add your internal domain here

s.linkLeaveQueryString=false;

s.linkTrackVars="None";

s.linkTrackEvents="None";

/*

* Plugin: getNewRepeat 1.2 - Returns whether user is new or repeat

*/

s.getNewRepeat=new Function("d","cn",""

+"var s=this,e=new Date(),cval,sval,ct=e.getTime();d=d?d:30;cn=cn?cn:"

+"'s_nr';e.setTime(ct+d*24*60*60*1000);cval=s.c_r(cn);if(cval.length="

+"=0){s.c_w(cn,ct+'-New',e);return'New';}sval=s.split(cval,'-');if(ct"

+"-sval[0]<30*60*1000&&sval[1]=='New'){s.c_w(cn,ct+'-New',e);return'N"

+"ew';}else{s.c_w(cn,ct+'-Repeat',e);return'Repeat';}");

/*

* Utility Function: split v1.5 (JS 1.0 compatible)

*/

s.split=new Function("l","d",""

+"var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x"

+"++]=l.substring(0,i);l=l.substring(i+d.length);}return a");

s.usePlugins=true;

s.doPlugins=function(s) {

   

s.eVar13 = s.getNewRepeat(30,'s_getNewRepeat');

};

//s.doPlugins=s_doPlugins;

s.trackingServer="sstats.adobe.com";

s.trackingServerSecure="tealiumecommerce.sc.omtrdc.net";

Regards,

Jay.

Avatar

Employee

Please check the Tealium library load. This line of code is the correct format of calling the plugin. It could be related to the way Tealium load the library code.

Avatar

Employee

Please check the Tealium library load. This line of code is the correct format of calling the plugin. It could be related to the way Tealium load the library code.

Avatar

Level 3

Sure Hari, thanks for your reply. Will check and get back to you.

Avatar

Level 3

Hi Hari,

Suggested -- Place the following code within the s_doPlugins() function, which is located in the area of the s_code.js file labeled Plugin Config .

Since I am using AppMeasurement for JS tag in Tealium IQ I don't find exact s_code.js. So I was trying to implement in above the app measurement function call on the tag template after editing and also in different format on the tag but still I don't see my prop4 is firing. Therefore, where is the exact and correct place to implement the plugin code on this AppMeasurement for JS tag.

Please suggest me to take necessary action to fire this plugin.

Thank you,
Jay.

Avatar

Community Advisor

I do not think you need to implement this plugin nowadays.

I think Analysis Workspace has a dimention by default (might need to double check). Or you can use segmentation as described here:

Compare new visitors to return visitors

To use doPlugins in a tag management system then watch the video here Use doPlugins in the Adobe Analytics Extension

It would help you understand how to use it. This documentation should help you as well:

Call plug-ins with doPlugins function

All plugins should be outside the doPlugins function.

I usually put a console.log in the doPlugins function to understand when it is called. Did you try this?

Avatar

Level 10
Do any of the answers below answer your initial question? If so, can you select one of them as the correct answer? If none of the answers already provided answer your question, can you provide additional information to better help the community solve your question?