This plug-in is provided by Adobe Consulting as a courtesy to help you get more value out of Adobe Analytics. Adobe Customer Care does not provide support with this plug-in, including installation or troubleshooting. If you require help with this plug-in, contact your organization’s Account Manager. They can arrange a meeting with a consultant for assistance.
The getNewRepeat
plug-in allows you to determine whether a visitor to the site is a new visitor or a repeat visitor within a desired number of days. Adobe recommends using this plug-in if you want to identify visitors as “new” using a custom number of days. This plug-in is unnecessary if the New/Repeat visitor dimensions in Analysis Workspace meet your organization’s needs.
Adobe offers an extension that allows you to use most commonly-used plug-ins.
If you do not want to use the plug-in extension, you can use the custom code editor.
Copy and paste the following code anywhere in the AppMeasurement file after the Analytics tracking object is instantiated (using s_gi
). Preserving comments and version numbers of the code in your implementation helps Adobe with troubleshooting any potential issues.
/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: getNewRepeat v2.1 */
s.getNewRepeat=function(d){d=d?d:30;var s=this,p="s_nr"+d,b=new Date,e=s.c_r(p),f=e.split("-"),c=b.getTime();b.setTime(c+864E5*d); if(""===e||18E4>c-f[0]&&"New"===f[1])return s.c_w(p,c+"-New",b),"New";s.c_w(p,c+"-Repeat",b);return"Repeat"};
/******************************************** END CODE TO DEPLOY ********************************************/
The getNewRepeat
method uses the following arguments:
d
(integer, optional): The minimum number of days required between visits that resets visitors back to "New"
. If this argument is not set, it defaults to 30 days.This method returns the value of "New"
if the cookie set by the plug-in doesn’t exist or has expired. It returns the value of "Repeat"
if the cookie set by the plug-in exists and the amount of time since the current hit and the time set in the cookie is greater than 30 minutes. This method returns the same value for an entire visit.
This plug-in uses a cookie named "s_nr[LENGTH]"
where [LENGTH]
is equal to the d
argument. The cookie contains a Unix timestamp representing the current time and the current status of the visitor ("New"
or "Repeat"
).
The following code will set s.eVar1 equal to the value of “New” for new visitors and will continue to set s.eVar1 equal to the value of “New” (with each new call) throughout the remainder of the visitor’s visit to the site.
s.eVar1=s.getNewRepeat();
If the visitor comes back to the site anytime from 31 minutes to 30 days since the last time s.getNewRepeat() was called, the following code will set s.eVar1 equal to the value of “Repeat” and will continue to set s.eVar1 equal to the value of “Repeat” (with each new call) throughout the remainder of the visitor’s visit to the site.
s.eVar1=s.getNewRepeat();
If the visitor hasn’t been to the site for at least 30 days since the last time s.getNewRepeat() was called, the following code will set s.eVar1 equal to the value of “New” and will continue to set s.eVar1 equal to the value of “New” (with each new call) throughout the remainder of the visitor’s visit to the site.
s.eVar1=s.getNewRepeat();
If the visitor comes back to the site anytime 31 minutes to 365 days (i.e. 1 year) since the last time s.getNewRepeat() was called, the following code will set s.eVar1 equal to the value of “Repeat” and will continue to set s.eVar1 equal to the value of “Repeat” (with each new call) throughout the remainder of the visitor’s visit to the site.
s.eVar1=s.getNewRepeat(365);
If the visitor hasn’t been to the site for at least 365 days (i.e. 1 year) since the last time s.getNewRepeat() was called, the following code will set s.eVar1 equal to the value of “New” and will continue to set s.eVar1 equal to the value of “New” (with each new call) throughout the remainder of the visitor’s visit to the site.
s.eVar1=s.getNewRepeat(365);
d
argument.