Adobe Analytics getPageVisibility plugin



My goal is to catch the amount of time the page was active within the browser and define this value to eVar

I found this plugin getPageVisibility , but it suggests to define value to events.

Could anyone describe how to config this plugin to push the value (Total Page Visibility Seconds) only in eVar

Accepted Solutions (1)

Accepted Solutions (1)



Configured. Redesign a little bit plugin (also added s.getVisitStart function, which is missed in documentation)

/* Plugin: Visit Start */

s.getVisitStart = new Function("c", "var s=this,v=1,t=new Date;t.setTime(t.getTime()+1800000);if(s.c_r(c)){v=0}if(!s.c_w(c,1,t)){s.c_w(c,1,0)}if(!s.c_r(c)){v=0}return v;");

/* Page Visibility Plugin 0.1 (BETA) */

s.getPageVisibility=new Function("",""

+"var s=this;if(s.getVisitStart()){s.Util.cookieWrite('s_pvs','');s.U"






s.gbp=new Function("",""

+"if('hidden'in document){return null;}var bp=['moz','ms','o','webkit"

+"'];for(var i=0;i<bp.length;i++){var p=bp[i]+'Hidden';if(p in docume"

+"nt){return bp[i];}}return null;");

s.hp=new Function("p",""

+"if(p){return p+'Hidden';}else{return'hidden';}");

s.vs=new Function("p",""

+"if(p){return p+'VisibilityState';}else{return'visibilityState';}"); Function("p",""

+"if(p){return p+'visibilitychange';}else{return'visibilitychange';}");

s.pvx=new Function("",""


s.wpvc = function(){var tempDate =;s.Util.cookieWrite('s_tps',

Math.ceil((tempDate - s.totalTime)/1000));s.Util.cookieWrite('s_pvs', s.pvt)}

document.addEventListener('visibilitychange',function(event){if(document.hidden){s.visibility = false;clearTimeout(s.pvi);}else{s.visibility=true;s.pvi=setInterval(s.pvx,1000);}});s.totalTime=new Date();s.pvt=0;s.prefix=s.gbp;s.hidden=s.hp(s.prefix);s.visibility=true;s.visibilityState=s.vs(s.prefix);;

and added following rows to doPlugins function

if (s.c_r("s_tps") > 0)

    s.eVar10= s.c_r("s_tps");


Answers (2)

Answers (2)



Yes, I see. But we don't need eVar for previous page name. We just want to define Total Page Visibility to eVar (not to events as how in documentation mention s.pvel='event7,event8,event9'), something like this s.pvel=' ,eVar10, '




Hi Cathyc,

The plugins requires 4 variables: one eVar for capturing the pageName value and 3 events (two of them are optional) that will become metrics. If you implement it according to that documentation, all the values will be set automatically.

So in your case the minimal setup will contain one eVar and one event that you need to configure in the report suite manager and also set in the implementation code (see the doc).