getValOnce

The getValOnce plug-in prevents a given variable from being set to the previously defined value. It uses a cookie to determine a variable's last seen value. If the current value matches the cookie value, the variable is overwritten with a blank string before it is sent to Adobe's processing servers. This plug-in is useful to prevent conversion variable instance inflation caused when users refresh the page or click the Back button.

Important: This plug-in has not been validated to be compatible with AppMeasurement for JavaScript. See AppMeasurement Plug-in Support.

Parameters

s.eVar1=s.getValOnce(variable,cookie,expiration,minute);

Properties

Note: The following instructions require you to alter the data collection code on your site. This can affect data collection on your site, and should only be done by a developer with experience using and implementing Analytics.

Implementation

Note: If your organization uses Marketing Channels and has rules set up based on s.campaign, it is recommended that you not use the getValOnce plugin when setting the s.campaign value. Doing so could lead to an incorrect channel being assigned on a secondary campaign click-through.

To implement this plug-in, place the following code within your s_code.js file

/********************************************************************
 *
 * Main Plug-in code (should be in Plug-ins section)
 *
 *******************************************************************/
/*
 * Plugin: getValOnce_v1.11
 */
s.getValOnce=new Function("v","c","e","t",""
+"var s=this,a=new Date,v=v?v:'',c=c?c:'s_gvo',e=e?e:0,i=t=='m'?6000"
+"0:86400000,k=s.c_r(c);if(v){a.setTime(a.getTime()+e*i);s.c_w(c,v,e"
+"==0?0:a);}return v==k?'':v");

Once the above code is implemented, define the desired variable using the getValOnce function. The following are several examples on how it can be implemented:

Preventing the same campaign value from being defined if a duplicate value is detected within 30 days of cookie being set:

s.campaign=s.getValOnce(s.campaign,'s_cmp',30);

Prevents the same eVar1 value from being defined if a duplicate value is detected within 30 minutes of the cookie being set:

s.eVar1=s.getValOnce(s.eVar1,'s_ev1',30,'m');

Prevents the same eVar2 value from being defined multiple times in the same browser session:

s.eVar2=s.getValOnce(s.eVar2,'s_ev2');
Notes
  • Always test plug-in installations extensively to ensure that data collection is as expected before deploying in a production environment.
  • Make sure you delete the cookie or use new, unique values during testing or variables will not be sent.